• 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
HTML hexidecimal code from NSColor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

HTML hexidecimal code from NSColor


  • Subject: HTML hexidecimal code from NSColor
  • From: Francisco Tolmasky <email@hidden>
  • Date: Thu, 15 May 2003 19:51:56 -0700

Given an NSColor object, how do I create a string with the HTML hexadecimal color codes?

I tried this:

- (NSString *)colorString
{
float red, green, blue;
[[color colorUsingColorSpaceName: NSCalibratedRGBColorSpace]
getRed: &red green: &green blue: &blue alpha: nil];
return [NSString stringWithFormat: @"%X%X%X", red, green, blue];
}

This doesn't work though, since the numbers returned are between 0.0 and 1.0, not 0 and 255. Does anyone know how to get it to work?

Francisco Tolmasky
email@hidden
http://users.adelphia.net/~ftolmasky
_______________________________________________
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.

  • Follow-Ups:
    • Re: HTML hexidecimal code from NSColor
      • From: "Clark S. Cox III" <email@hidden>
    • Re: HTML hexidecimal code from NSColor
      • From: Scott Anguish <email@hidden>
  • Prev by Date: Re: Some questions...
  • Next by Date: printing over-optimizing ?
  • Previous by thread: WSMethodInvocationInvoke and Microsoft TerraServer?
  • Next by thread: Re: HTML hexidecimal code from NSColor
  • Index(es):
    • Date
    • Thread