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: When is (NSColor) black not black?




On May 2, 2005, at 1:36 PM, glenn andreas wrote:

If what you want to do is see if it really is "black", you can do something like:


    if ([[[colorWheel color] colorUsingColorSpaceName: NSCalibratedWhiteColorSpace] whiteComponent] == 0.0)

        // we've got black


If you want to see if the color in the picker is "the same" as any other given color, first try converting to the appropriate color space (and it would be up to you to decide which color space that is, be it RGB, CMYK, white and calibrated or device specific).  You may want to also figure out if the alpha component matters (are two colors that have the same color components with different alphas the same color?  Depends on your needs...)



When you do something like this, you should be sure to check that the result of colorUsingColorSpaceName: is not nil.  Not all conversions are possible.

Douglas Davidson

 _______________________________________________
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: 
 >When is (NSColor) black not black? (From: Mark Dawson <email@hidden>)
 >Re: When is (NSColor) black not black? (From: glenn andreas <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.