Re: Clearing an NSView
Re: Clearing an NSView
- Subject: Re: Clearing an NSView
- From: Greg Titus <email@hidden>
- Date: Tue, 24 Jul 2001 11:10:25 -0700
On Tuesday, July 24, 2001, at 07:29 AM, Phil Barrett wrote:
I have an NSView used as an overlay, so it's mostly transparent. I draw
something into it. I then want to clear it back to transparent again.
But
how do I do this?
[[NSColor clearColor] set]; [NSBezierPath fillRect:bounds]; doesn't
work,
because filling with transparent has no effect.
The normal fill and stroke operations composite the color over whatever
is there before (and thus drawing completely transparently does
nothing). Instead you want to copy the color over the bounds, ignoring
whatever was there before. To do this you need to use a different
operation: the copy operation.
[[NSColor clearColor] set];
NSRectFillUsingOperation(bounds, NSCompositeCopy);
(Look up NSCompositingOperation for all sorts of interesting effects you
can get with compositing...)
Hope this helps,
--Greg