• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Draw image within a NSBezierPath with no border
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Draw image within a NSBezierPath with no border


  • Subject: Re: Draw image within a NSBezierPath with no border
  • From: Leonardo <email@hidden>
  • Date: Thu, 06 Mar 2014 18:25:21 +0100
  • Thread-topic: Draw image within a NSBezierPath with no border

That's make sense. Do you know any workaround?
I have to draw the background color because:
    1) the user could choose to see a background color on the area not
covered by the image. Let's imagine a circle divided in 3 slices by two
vertical lines. In the middle we have the image, and on the left and right
areas we see the color. So, at the top and bottom of the image I see that
bad blue curved border.
    2) In case of shadow, if I do not fill with a color before clipping the
path I can't get the shadow out of the path. If I do

CGContextSetShadowWithColor...
[fillPath addClip];
[image drawInRect:fillBounds fromRect:NSZeroRect
operation:NSCompositeSourceOver fraction:1.0];

I can't get the shadow out of the fillPath.
Instead If I do:

CGContextSetShadowWithColor...
    [aBlueColor set];
    [fillPath fill];
RemoveShadow
    [fillPath addClip];
    [image drawInRect:fillBounds fromRect:NSZeroRect
    operation:NSCompositeSourceOver fraction:1.0];

The problem is that I must clip the path before drawing the image, and as
result the image itself can't project shadow outside the clipped path.
I am puzzled.


Regards
-- Leonardo


> Da: Kyle Sluder <email@hidden>
> Data: Thu, 6 Mar 2014 09:02:00 -0800
> A: Leonardo <email@hidden>
> Cc: "email@hidden" <email@hidden>
> Oggetto: Re: Draw image within a NSBezierPath with no border
>
> On Mar 6, 2014, at 8:34 AM, Leonardo <email@hidden> wrote:
>>
>> Hi, I have an oval NSBezierPath path. I fill it with a blue color,
>> then I draw an image within the same path. And I can still see a blue tiny
>> border around the image. I would expect the color be never visible since the
>> image covers the whole area. That's my code:
>>
>> fillPath = [NSBezierPath bezierPathWithOvalInRect:fillBounds];
>> [aBlueColor set];
>> [fillPath fill];
>> [fillPath addClip];
>> [image drawInRect:fillBounds fromRect:NSZeroRect
>> operation:NSCompositeSourceOver fraction:1.0];
>>
>> Even if I draw the image in a bigger rect, the blue border is still there.
>> What do I miss?
>
> Due to antialiasing, the fringes of your mask have alpha < 1.
>
> Let¹s say there¹s a pixel on the fringe of your mask that winds up with alpha
> 0.5. Using your code, that pixel's final color will be 0.5 * (0.5 * Original
> background color + 0.5 * blue) + 0.5 * (color from image).
>
> --Kyle Sluder



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Draw image within a NSBezierPath with no border
      • From: Kyle Sluder <email@hidden>
References: 
 >Re: Draw image within a NSBezierPath with no border (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Draw image within a NSBezierPath with no border
  • Next by Date: Re: Draw image within a NSBezierPath with no border
  • Previous by thread: Re: Draw image within a NSBezierPath with no border
  • Next by thread: Re: Draw image within a NSBezierPath with no border
  • Index(es):
    • Date
    • Thread