Drawing operations

The drawing operation is fixed for the special purpose attribute bundles, and is specified in the constructor for TGrafBundle. The special purpose attribute bundles have a Get function to retrieve the drawing operation. TGrafBundle, however, lets you Get and Set the drawing operation. The drawing operation is defined by an enumeration value of type EDrawOperation that can be one of the following values:

kFill: The geometry is filled.

kFrame: The geometry is framed.

kFillAndFrame: The geometry is filled and framed.

The following code fragment creates a black frame, a gray fill, and a fill and frame bundle that uses these color paints. The pen width is set to 5.0 using the AdoptFramePen function. See the heading "Frame pen styles" on page 158 for information on pen styles. This fill and frame attribute bundle is passed to the drawing port to draw the polygon shown in Figure 95.


      TColorPaint* blackFrame = new TColorPaint( TRGBColor( 0, 0, 0 ) );
      TColorPaint* grayFill = new TColorPaint( TRGBColor( .75, .75,.75 ) );
      TGrafBundle polyBundle( grayFill, blackFrame, TAttributeState::kFillAndFrame );
      
      TSolidPen* centerFramePen = new TSolidPen( 5.0 );
      polyBundle.AdoptFramePen( centerFramePen );
      
      TGPolygon aPolygonGeometry;
      aPolygonGeometry.Append( TGPoint( 15, 30 ) );
      aPolygonGeometry.Append( TGPoint( 25, 100 ) );
      aPolygonGeometry.Append( TGPoint( 150, 50 ) );
      
      thePort.Draw( aPolygonGeometry, polyBundle );

Change drawing operation

Use the SetDrawingOperation function to change the drawing operation. You get the following behaviors from the different drawing operations:

kFill: When the drawing operation is kFill, the geometry is filled using the fill color paint.

kFrame: When the drawing operation is kFrame, the geometry is framed using the frame color paint.

kFillAndFrame: When the drawing operation is kFillAndFrame, the geometry is filled and framed using the fill and frame color paints.

Change colors

Use the AdoptFillPaint and AdoptFramePaint functions to adopt a new fill or frame paint to the bundle. For example, you can create a frame bundle, adopt a fill paint, and change the drawing operation to either kFill or kFillAndFrame to use the fill paint.

If you already have fill or frame paints specified, you can change them by adopting the new paint with the OrphanFillPaint and OrphanFramePaint functions.

Example

The following code creates a fill bundle, adopts a frame paint, and changes the drawing operation to kFillAndFrame. This bundle is used to fill and frame the polygon in Figure 95.

      TColorPaint* grayFill = new TColorPaint( TRGBColor( .75, .75, .75 ) );
      TGrafBundle polyBundle( grayFill, TAttributeState::kFill );
      
      TColorPaint* blackFrame = new TColorPaint( TRGBColor( 0, 0, 0 ) );
      polyBundle.AdoptFramePaint( blackFrame );
      polyBundle.SetDrawingOperation( TAttributeState::kFillAndFrame );

[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