Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shiny little square buttons



Am 03.07.2006 um 21:04 schrieb Gerd Knops:
On Jul 3, 2006, at 4:23 AM, Uli Kusterer wrote:

NSRectFill & Co. are for *replacing* a color in a rect (e.g. to reset the alpha channel of an NSImage). Why does everybody insist on using the functions when we have a perfectly good fillRect method in NSBezierPath?

And the difference/reason to use one over the other would be? They both fill a rectangle with a color, right?

Yes, but the alpha value is handled differently. Example:

[[NSColor clearColor] set];

[NSBezierPath fillRect: [self bounds]]; // Does nothing. Transparent drawings are painted on top of whatever's there.
NSRectFill( [self bounds] ); // Clears the entire rectangle of drawings.


I should correct what I said earlier: If you use the correct drawing mode ("operation"), NSRectFillUsingOperation() will probably work as well, but since NSRectFill() uses the "copy" mode, it'll overwrite any alpha and colour information that may already be there, while [NSBezierPath fillRect:] automatically uses the mode most people would expect.

Most problems with NSRectFill() I've seen so far were due to people not expecting it to use the "copy" mode.

Cheers,
-- M. Uli Kusterer
http://www.zathras.de


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Shiny little square buttons (From: Nik Youdale <email@hidden>)
 >Re: Shiny little square buttons (From: Jeremy Dronfield <email@hidden>)
 >Re: Shiny little square buttons (From: Nik Youdale <email@hidden>)
 >Re: Shiny little square buttons (From: Uli Kusterer <email@hidden>)
 >Re: Shiny little square buttons (From: Gerd Knops <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.