Re: colorWithAlphaComponent: weirdness
Re: colorWithAlphaComponent: weirdness
- Subject: Re: colorWithAlphaComponent: weirdness
- From: Greg Titus <email@hidden>
- Date: Mon, 29 Sep 2003 12:47:14 -0700
On Monday, September 29, 2003, at 12:14 PM, Finlay Dobbie wrote:
I've come across some weird behaviour with drawing colors which have
an alpha component.
In your custom view subclass, do something like this:
- (void)drawRect:(NSRect)rect {
[[[NSColor blueColor] colorWithAlphaComponent:0.5] set];
NSRectFill(rect);
}
Now run your application. It looks fine. Then, click the minimize
button. Uh, wtf? Why did that window suddenly get a translucent hole
in it?
A project demonstrating this can be found at
<http://z.dobbie.net/ViewWeirdness.tar.gz>. Just run it and then
minimize the window. You'll see the WeirdView suddenly change for no
apparent reason, then when you deminimize it you'll see it flick back
again when the animation finishes.
Can anybody shed any insight onto this?
You see this because NSRectFill() is for painting directly onto your
view without doing any compositing, and when you draw alpha directly
onto your window, you get transparency in the window. Except that you
don't have the window flagged as containing alpha so Quartz has an
optimization that disables compositing where your window is, so you
only see the transparency during minimize.
If you wanted to composite your half-blue rectangle with the
background, you should be calling NSRectFillUsingOperation(rect,
NSCompositeSourceOver)...
Hope this helps,
- Greg
_______________________________________________
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.