Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: 3D Graphics Programming With QuickDraw 3D /
Chapter 21 - QuickDraw 3D Color Utilities


Using the QuickDraw 3D Color Utilities

You can use the 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 QuickDraw 3D 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 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 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.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996




Navigation graphic, see text links

Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help