Using the QuickDraw 3D Color Utilities
You can use theQ3ColorRGB_Set
function to set the fields of an RGB color structure. For example, to specify the color white, you can callQ3ColorRGB_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 QuickDraw 3D Color Utilities operate on two existing colors and return a third color. For example, you can call theQ3ColorRGB_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 themyResult
parameter 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 themyColor1
andmyColor2
parameters and adds that sum to the color specified by themyColor3
parameter. If this line of code completes successfully, the parametermyResult
is a pointer to an RGB color structure that contains the sum of all three colors.
Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help