Re: NSShadow with [bezierPath addClip]
Re: NSShadow with [bezierPath addClip]
- Subject: Re: NSShadow with [bezierPath addClip]
- From: Leonardo <email@hidden>
- Date: Thu, 02 Jan 2014 11:21:33 +0100
- Thread-topic: NSShadow with [bezierPath addClip]
Many thanks David. That did the trick.
Regards
-- Leonardo
> Da: David Duncan <email@hidden>
> Data: Wed, 01 Jan 2014 17:44:01 -0800
> A: Leonardo <email@hidden>
> Cc: Cocoa-dev <email@hidden>
> Oggetto: Re: NSShadow with [bezierPath addClip]
>
> In CoreGraphics the way you would do this is to setup your shadow parameters,
> then start a transparency layer, do your drawing there, then composite that
> back to the original context. Something like this:
>
> CGContextSetShadow(context, shadowOffset, shadowBlur);
> CGContextBeginTransparencyLayer(context, NULL);
> // do your drawing
> CGContextEndTransparencyLayer(context);
>
> You could get the graphicsPort from the NSGraphicsContext to call the
> transperancy layer methods and otherwise stick to NSGraphics stuff.
>
> On Dec 31, 2013, at 4:15 AM, Leonardo <email@hidden> wrote:
>
>> In my NSView subclass, I have to draw an image within a bezierPath and apply
>> an NSShadow to the result.
>> So within the drawRect: method I add
>>
>> [bezierPath addClip];
>> [mImage drawInRect:inRect fromRect:fromRect
>> operation:NSCompositeSourceOver fraction:mOpacity];
>>
>> It works. The image gets clipped by the path.
>> Now I would like to apply the NSShadow to the result, so before those lines
>> above I add
>>
>> [bezierPath addClip];
>> [mShadow set];
>> [mImage drawInRect:inRect fromRect:fromRect operation:NSCompositeSourceOver
>> fraction:mOpacity];
>>
>> I can't get the shadow drawn because the bezierPath is clipping the drawing
>> area where the shadow should fall.
>> How to solve this trouble?
>> I have tried to use a layer, but I get weird results when I resize, rotate
>> and modify other parameters of the view.
>>
>>
>> Regards
>> -- Leonardo
>>
>>
>> _______________________________________________
>>
>> 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
>
> --
> David Duncan
>
_______________________________________________
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