[comp.sys.mac.programmer] Changing the darkness of a Color

mikeoro@hubcap.clemson.edu (Michael K O'Rourke) (07/26/89)

I am new to Color QuickDraw and i have what is probably an easy question.

If i have a color chosen from the Color Picker, i.e. an RGBColor record,
how can i get colors ranging from white to that color.  For instance, if the
user picks a dark blue i want to go from white to dark blue, but ALWAYS be
a blue, no reds or yellows.        

Is this easy to do?

Michael O'Rourke

rick@Jessica.stanford.edu (Rick Wong) (07/28/89)

In article <6073@hubcap.clemson.edu> mikeoro@hubcap.clemson.edu (Michael K O'Rourke) writes:
>If i have a color chosen from the Color Picker, i.e. an RGBColor record,
>how can i get colors ranging from white to that color.  For instance, if the
>user picks a dark blue i want to go from white to dark blue, but ALWAYS be
>a blue, no reds or yellows.        
>
>Michael O'Rourke

I'm not too familiar with color models, but a little playing with the
Color Picker shows that you want to be working with HSV (hue, saturation,
value/brightness) colors.  The hue determines whether it's reddish, bluish,
or whatever.  White corresponds to minimal saturation (0) and maximum
brightness (65535).  Therefore, to go from white to some target color {H,S,V}
would require starting at {H,0,65535} and varying the saturation and value
so that they eventually reach the target saturation and value.

Fortunately, the Color Picker Package provides conversion routines (HSV2RGB
and RGB2HSV) that translate between RGB and HSV colors.

Rick Wong
rick@jessica.stanford.edu