• 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: How to make an NSColor correspond to a grayscale value?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make an NSColor correspond to a grayscale value?


  • Subject: Re: How to make an NSColor correspond to a grayscale value?
  • From: "John C. Randolph" <email@hidden>
  • Date: Tue, 20 Aug 2002 14:58:44 -0700

On Tuesday, August 20, 2002, at 02:51 PM, Ondra Cada wrote:


On Tuesday, August 20, 2002, at 11:19 , John C. Randolph wrote:

How can I make an NSColor represent a grayscale color, which value is
between 0 and 255?

int howBright; // something between 0 and 255
NSColor *myGreyLevel = [NSColor colorWithCalibratedWhite:howBright/255 alpha:1.0];

Add at least one dot ("255."), lest the colour stays black ;)

Whoops!

Ondra's right. The compiler won't promote the term howBright/255 to float until after the division is done, and integer division isn't very useful here.

-jcr

John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
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.

References: 
 >Re: How to make an NSColor correspond to a grayscale value? (From: Ondra Cada <email@hidden>)

  • Prev by Date: Adding a drawer to a window?
  • Next by Date: Re: How to make an NSColor correspond to a grayscale value?
  • Previous by thread: Re: How to make an NSColor correspond to a grayscale value?
  • Next by thread: Re: How to make an NSColor correspond to a grayscale value?
  • Index(es):
    • Date
    • Thread