As of Leopard, when I attempt to draw a linear gradient
(CILinearGradient) via any kind of context--an NSImage, an NSView
drawing itself (flipped or not), etc--the gradient start and end
colours are backwards. That is, if I start the gradient at black and
end it at white, it will appear on-screen as though I started at
white and ended at black. In Tiger, I did not have this problem.
I draw the gradient inside of an NSBezierPath category:
// extract the CIImage from the filter pipeline
gradientImage = [gradientFilter valueForKey:@"outputImage"];
// save the current graphics state and push a new drawing context
onto the stack
[currentContext saveGraphicsState];
// obtain the current graphics context
ciGraphicsContext = [currentContext CIContext];
// clip the context to the bezier path
[self addClip];
// draw into the current graphics context
[ciGraphicsContext drawImage:gradientImage atPoint:CGPointMake
(pathBounds.origin.x, pathBounds.origin.y) fromRect:CGRectMake
(pathBounds.origin.x, pathBounds.origin.y, pathBounds.size.width,
pathBounds.size.height)];
// restore previous graphics state
[currentContext restoreGraphicsState];
}
What am I doing incorrectly that just happens to work in Tiger, but
not in Leopard? If I'm drawing an image that an NSView renders, or
using this code with an NSView that's drawing itself, it doesn't seem
to make a difference if the view is flipped or not. The gradient is
always "backwards".
--
mikey-san
_______________________________________________
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