Using the QuickDraw 3D Color Utilities
You can use theQ3ColorRGB_Setfunction to set the fields of an RGB color structure. For example, to specify the color white, you can callQ3ColorRGB_Setas 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 QuickDraw 3D Color Utilities operate on two existing colors and return a third color. For example, you can call theQ3ColorRGB_Addfunction 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_Addreturns the address of the resulting RGB color structure both in themyResultparameter and as its function result. This allows you to nest calls to the QuickDraw 3D 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 themyColor1andmyColor2parameters and adds that sum to the color specified by themyColor3parameter. If this line of code completes successfully, the parametermyResultis a pointer to an RGB color structure that contains the sum of all three colors.