I've noticed I'm getting different results with NSGradient when drawing to screen and when drawing in a PDF context, e.g. printing, or write PDF to clipboard. If the gradient contains colours with transparency, it draws correctly on-screen (allowing what's drawn behind to come through), but draws opaquely in PDF.

I have tried forcing the compositing operation of the context to NSCompositeSourceOver just before drawing the gradient, but to no avail.

Anyone else noticed this, or am I doing something wrong? Example code fragment below:



NSGradient* grad = [[NSGradient alloc] initWithStartingColor: [[NSColor whiteColor] colorWithAlphaComponent:0.2] endingColor: [NSColor blackColor]];

        // set up of start/end points and path not shown

        [NSGraphicsContext saveGraphicsState];
        [path addClip];
[[NSGraphicsContext currentContext] setCompositingOperation:NSCompositeSourceOver];
                
[grad drawFromCenter:sp radius:sr toCenter:ep radius:er options:NSGradientDrawsBeforeStartingLocation | NSGradientDrawsAfterEndingLocation];
                
        [NSGraphicsContext restoreGraphicsState];



--Graham


_______________________________________________

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

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

Reply via email to