15 Most Recent [RSS]
More...
|
NSRectFill considered harmful
One of the most unfortunate citizens of Cocoa's AppKit is NSRectFill(). Why? Because NSRectFill( box ) is a shortcut for NSRectFillUsingOperation( box, NSCompositeCopy ). And the "copy" mode means that no compositing takes place. So, if you try to fill a 50% opaque rectangle with
[[NSColor colorWithDeviceRed: 0 green: 0 blue: 0 alpha: 0.5] set];
NSRectFill( box )
You get a nice, 100% opaque black box. Instead, you want to use:
[[NSColor colorWithDeviceRed: 0 green: 0 blue: 0 alpha: 0.5] set];
[NSBezierPath fillRect: box];
So, my suggestion is: Forget about those functions in NSGraphics.h whenever there's a method that does the same. You'll save yourself a lot of pain.
| |