3D Graphics Programming with QuickDraw 3D
Q3ColorRGB_Set
function to set the fields of an RGB color structure. For example, to specify the color white, you can call Q3ColorRGB_Set
as shown in Listing 21-1.Listing 21-1 Specifying the color white
TQ3ColorRGB myColor; Q3ColorRGB_Set(&myColor, 1.0, 1.0, 1.0);Most of the QuickDraw3D Color Utilities operate on two existing colors and return a third color. For example, you can call the
Q3ColorRGB_Add
function to add together two colors, as shown in Listing 21-2.Listing 21-2 Adding two colors
TQ3ColorRGB myColor1, myColor2, myResult; TQ3ColorRGB *myResultPtr; myResultPtr = Q3ColorRGB_Add(&myColor1, &myColor2, &myResult);As you can see,
Q3ColorRGB_Add
returns the address of the resulting RGB color structure both in the myResult
parameter and as its function result. This allows you to nest calls to the QuickDraw3D Color Utilities in function calls, as follows:
Q3ColorRGB_Add(Q3ColorRGB_Add(&myColor1, &myColor2, &myResult), &myColor3, &myResult);This line of code adds the colors specified by the
myColor1
and myColor2
parameters and adds that sum to the color specified by the myColor3
parameter. If this line of code completes successfully, the parameter myResult
is a pointer to an RGB color structure that contains the sum of all three colors.
Let us know what you think of these prototype pages.
Generated with Harlequin WebMaker