Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Color in Cocoa



In working through many of the tutorials on the web
and in Learning Cocoa, I have learned how to change
the color to redColor, blueColor, blackColor, etc.

But how do you set the RGB and alpha values directly
in code (not using the colorwell)? I looked in the
NSColor.h file, but do not see any calls like that or
even a structure for NSColor objects. All the calls
seem to return the values rather than set them. If I
knew that NSColor was defined as having "red","green",
"blue", and "alpha" short variables (for example),
then I could set them a la

NSColor color;

color.blue = 3000;
color.red = 1500;
etc.

The only hint I had at more complex colors was on page
346 of Learning Cocoa where CGContexts are mentioned.
Here there is a call to CGContextSetRGBFillColor().
This supposedly would do what I want, but do I have to
create a context to get access to "millions" of
colors? If I am trying to draw a colorful mandelbrot
set, could contexts be the best way for me to draw
them?

Any suggestions would be helpful. Thank you.

Alexander
Send your FREE holiday greetings online!
http://greetings.yahoo.com




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.