Hi David,
After a few days using CGContextBeginTransparencyLayer
I have just noticed that the text I draw on a trasparent background with

    [super drawRect:rect];  // we are in a drawRect: method of a NSTextView

looks without antialias. No matter whether I add before

    CGContextSetAllowsAntialiasing(context, YES);
    CGContextSetShouldAntialias(context, YES);
    
    CGContextSetAllowsFontSmoothing (context, true);
    CGContextSetShouldSmoothFonts (context, true);
    
    CGContextSetAllowsFontSubpixelPositioning(context, YES);
    CGContextSetShouldSubpixelPositionFonts(context, YES);
    
    CGContextSetAllowsFontSubpixelQuantization(context, YES);
    CGContextSetShouldSubpixelQuantizeFonts(context, YES);

If I eliminate CGContextBeginTransparencyLayer, the text gets properly
drawn. Do I still miss something?


Regards
-- Leonardo


> Da: David Duncan <david.dun...@apple.com>
> Data: Wed, 01 Jan 2014 17:44:01 -0800
> A: Leonardo <mac.iphone....@gmail.com>
> Cc: Cocoa-dev <cocoa-dev@lists.apple.com>
> 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 <mac.iphone....@gmail.com> 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 (Cocoa-dev@lists.apple.com)
>> 
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com
>> 
>> This email sent to david.dun...@apple.com
> 
> --
> David Duncan
> 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to