Color

Color classes are used for the frame, the inside and outside surface colors, and the ambient light in the scene bundle (see Chapter 17 for information on scene bundles). The default frame color is black, the default inside surface color is bright pink, and the default outside surface color is light gray. While the Color framework provides a rich selection of color classes for many purposes, the color classes you most often use in a graphics application are TRGBColor, TXYZColor, TGrayColor, and THSVColor, which all descend from TColor and are described in Chapter 7. You can also define colors as spectral samples to achieve advanced shading. The TGrafBundle3D functions for adopting inside and outside colors are shown in Figure 191.


      virtual void AdoptInsideColor( TColor* insideColor );
      virtual void AdoptOutsideColor( TColor* outsideColor );
The following code fragment creates the hollow cylinder sweeps shown inFigure 192.


    1  TGLoop contour( TGEllipse( TGRect( 0, 0, 200, 200 ) ) );
    2  contour.ReverseDirection();
    3  
    4  TGCurve3D trajectory(   TGPoint3D( 100, 0, 100 ),
    5                          TGPoint3D( 100, 50, 100 ), 
    6                          TGPoint3D( 100, 75, 100), 
    7                          TGPoint3D( 100, 100, 100 ) );
    8  
    9  TSweep3D simpleSweep( contour, trajectory, TGPoint3D( 1, 0, 0 ) );
    10  
    11  TGrafBundle3D* surfaceBundle = new TGrafBundle3D(   new TRGBColor( .75, .75, .75),
    12                                                      TAttributeState::kFill );
    13  simpleSweep.AdoptBundle( surfaceBundle );
    14  simpleSweep.Draw( port );
    15  
    16  simpleSweep.TranslateBy( TGPoint3D( 200, 0, 0 ) );
    17  
    18  surfaceBundle->AdoptInsideColor( new TRGBColor( 0, 0, 1 ) );
    19  simpleSweep.Draw( port );
Lines 1 through 9: Create the hollow cylinder sweep.

Lines 11 through 14: Create a fill bundle with a light gray fill, adopt the bundle to the sweep, and draw the sweep.

Line 16: Translate the sweep 200 world-coordinate units in the positive x direction.

Lines 18 and 19: Adopt a blue inside color and draw the sweep in a new location with a new inside color.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker