• 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: colorWithAlphaComponent: weirdness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >colorWithAlphaComponent: weirdness (From: Finlay Dobbie <email@hidden>)

  • Prev by Date: Problems printing with WebKit
  • Next by Date: NSOpenPanel and handling events ?
  • Previous by thread: colorWithAlphaComponent: weirdness
  • Next by thread: NSOpenPanel and handling events ?
  • Index(es):
    • Date
    • Thread