Re: NSRectFill not supporting compositing?????
Re: NSRectFill not supporting compositing?????
- Subject: Re: NSRectFill not supporting compositing?????
- From: Quentin Mathé <email@hidden>
- Date: Tue, 20 May 2003 16:24:21 +0200
Le mardi, 20 mai 2003, ` 14:11 Europe/Paris, Stiphane Sudre a icrit :
I just discovered that NSRectFill was not supporting compositing. i.e.
if you have an alpha component on a NSColor, it's not taken into
account.
As this behavior is not described in the NSRectFill documentation
which is just stating:
Fills the passed rectangle with the current color.
Is this an imprecision in the documentation or a bug in NSRectFill?
You cannot do alpha drawing directly into a NSView with NSRectFill You
must use an NSImage to do it like that for example :
@implementation TheView
- (id)initWithFrame:(NSRect)frameRect
{
[super initWithFrame:frameRect];
image = [[NSImage alloc] initWithSize:NSMakeSize(25, 25)];
[image addRepresentation:[[NSCustomImageRep alloc]
initWithDrawSelector:@selector(customDraw:) delegate:self]];
return self;
}
- (void)drawRect:(NSRect)rect
{
[image drawAtPoint:NSZeroPoint fromRect:NSMakeRect(0, 0, 25, 25)
operation:NSCompositeSourceOver fraction:1.0];
}
- (void)customDraw:(NSCustomImageRep *)rep {
NSColor *color = [NSColor yellowColor];
color = [color colorWithAlphaComponent:0.3];
[color set];
NSRectFill(NSMakeRect(0, 0, 25, 25));
}
@end
To be more general we can said that the compositing support directly
in an NSView doesn't work very well (you get strange results in many
cases, I don't know why, I don't know if it's normal), the solution is
to use an intermediate NSImage to do special compositing with composite
operations
I must say I'm curious to know if in the future we will be able to do
rendering directly in NSView with whatever composite operations.
--
Quentin Mathi
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.