This section describes the QuickDraw 3D utilities you can use to handle colors. Because most of these routines return a pointer to an RGB color structure both as a function result and through the result parameter, you can nest these routines.
You can use the Q3ColorRGB_Set function to set the fields of an RGB color structure.
TQ3ColorRGB *Q3ColorRGB_Set (
TQ3ColorRGB *color,
float r,
float g,
float b);
You can use the Q3ColorARGB_Set function to set the fields of an ARGB color structure.
TQ3ColorARGB *Q3ColorARGB_Set (
TQ3ColorARGB *color,
float a,
float r,
float g,
float b);
You can use the Q3ColorRGB_Add function to add two colors.
TQ3ColorRGB *Q3ColorRGB_Add (
const TQ3ColorRGB *c1,
const TQ3ColorRGB *c2,
TQ3ColorRGB *result);
You can use the Q3ColorRGB_Subtract function to subtract one color from another.
TQ3ColorRGB *Q3ColorRGB_Subtract (
const TQ3ColorRGB *c1,
const TQ3ColorRGB *c2,
TQ3ColorRGB *result);
You can use the Q3ColorRGB_Scale function to scale a color.
TQ3ColorRGB *Q3ColorRGB_Scale (
const TQ3ColorRGB *color,
float scale,
TQ3ColorRGB *result);
You can use the Q3ColorRGB_Clamp function to clamp a color.
TQ3ColorRGB *Q3ColorRGB_Clamp (
const TQ3ColorRGB *color,
TQ3ColorRGB *result);
You can use the Q3ColorRGB_Lerp function to interpolate two colors linearly.
TQ3ColorRGB *Q3ColorRGB_Lerp (
const TQ3ColorRGB *first,
const TQ3ColorRGB *last,
float alpha,
TQ3ColorRGB *result);
The Q3ColorRGB_Lerp function returns, as its function result and in the result parameter, a pointer to an RGB color structure that is linearly interpolated between the two colors specified by the first and last parameters. The alpha parameter specifies the desired alpha value for the interpolation.
You can use the Q3ColorRGB_Accumulate function to accumulate colors.
TQ3ColorRGB *Q3ColorRGB_Accumulate (
const TQ3ColorRGB *src,
TQ3ColorRGB *result);
You can use the Q3ColorRGB_Luminance function to compute the luminance of a color.
float *Q3ColorRGB_Luminance (
const TQ3ColorRGB *color,
float *luminance);
The Q3ColorRGB_Luminance function returns, as its function result and in the luminance parameter, the luminance of the color specified by the color parameter. A color's luminance is computed using this formula:
luminance = (0.30078125 color.r ) + (0.58984375 color.g ) + (0.109375 color.b )