• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Clearing an NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • RE: Clearing an NSView
      • From: "Phil Barrett" <email@hidden>
References: 
 >Clearing an NSView (From: "Phil Barrett" <email@hidden>)

  • Prev by Date: Re: How to set the scrollers in an NSScrollView?
  • Next by Date: Re: Use of NSLog() for debugging
  • Previous by thread: Clearing an NSView
  • Next by thread: RE: Clearing an NSView
  • Index(es):
    • Date
    • Thread