• 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: When is (NSColor) black not black?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When is (NSColor) black not black?


  • Subject: Re: When is (NSColor) black not black?
  • From: glenn andreas <email@hidden>
  • Date: Mon, 2 May 2005 15:36:24 -0500


On May 2, 2005, at 1:06 PM, Mark Dawson wrote:

I'm not sure if I'm doing a compare wrong, but if I set my color wheel to black (10.3.9, using the "named" colors/3 section from left of color wheel), it doesn't seem to compare correctly:

if ([[colorWheel color] isEqual:[NSColor blackColor]])
doSomething; <--- never equals


My guess is that your color wheel's color is in RGBA space, and NSColor blackColor is in white space (combined with possible differences between device vs calibrated). As a result, it make look black, but that doesn't mean that it is "the same" as blackColor

Is there something further I need to do?


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...)


Glenn Andreas                      email@hidden 
<http://www.gandreas.com/> oh my!
quadrium | build, mutate, evolve | images, textures, backgrounds, art
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: When is (NSColor) black not black?
      • From: Douglas Davidson <email@hidden>
References: 
 >When is (NSColor) black not black? (From: Mark Dawson <email@hidden>)

  • Prev by Date: Using NSPropertyListSerialization with NSArray of NSDictionaries
  • Next by Date: Re: Cocoa Technologies Back-Story?
  • Previous by thread: When is (NSColor) black not black?
  • Next by thread: Re: When is (NSColor) black not black?
  • Index(es):
    • Date
    • Thread