Solid pen

A solid pen renders a solid line that is defined by a pen balance and a pen width. as shown in Figure 103


The constructors for TSolidPen are shown below. The empty constructor creates a TSolidPen instance with all values set to NIL.

      TSolidPen();
      TSolidPen( const TSolidPen& );
      TSolidPen( GCoordinate penWidth, EPenBalance balance );
penWidth: A floating point value that represents the deviceindependent width of the pen in world-coordinates.

balance: This enumerated parameter has the following values:

    kCenterFrame: The pen is centered over the border of the geometry for path and areaenclosing geometries.
    kInsetFrame: The pen fits exactly along the inside edge of a fill and covers the edge fill pixels of a filled areaenclosing geometry. An inset frame is used when you want to specify the outside edge of a frame with pixel perfection rules.
    kOutsetFrame: The pen fits exactly along the outside edge of a fill and touches the edge fill pixels for areaenclosing geometries. An outset frame is used for bordering the fill of a geometry.
NOTE If either kInsetFrame or kOutsetFrame is set for a line, polyline, or curve, the result is a kCenterFrame.

The code fragment creates the polygons with a wide black frames in Figure 103. The pen width is 10 worldcoordinate units. The polygon is created three times using a different pen balance each time. A centered pen balance is used first, followed by the inset pen balance, and the outset pen balance shown in Figure 103 from left to right.

To keep the code concise, the second and third polygons are not translated before being drawn so that they draw next to each other the way the do in the figure.

    1  TColorPaint* blackFrame = new TColorPaint( TRGBColor( 0, 0, 0 ) );
    2  TGrafBundle* polyBundle = new TGrafBundle( blackFrame, TAttributeState::kFrame );
    3  
    4  TGPolygon aPolygonGeometry;
    5  aPolygonGeometry.Append( TGPoint( 90, 55 ) );
    6  aPolygonGeometry.Append( TGPoint( 100, 125 ) );
    7  aPolygonGeometry.Append( TGPoint( 225, 75 ) );
    8  
    9  TPolygon* aPolygon = new TPolygon( aPolygonGeometry, polyBundle );
    10  
    11  TSolidPen* centerFramePen = new TSolidPen( 10, TPen::kCenterFrame );
    12  polyBundle->AdoptFramePen( centerFramePen );
    13  
    14  aPolygon->Draw( thePort );
    15      
    16  TSolidPen* insetFramePen = new TSolidPen( 10, TPen::kInsetFrame );
    17  polyBundle->AdoptFramePen( insetFramePen );
    18  
    19  aPolygon->Draw( thePort );
    20  
    21  TSolidPen* outsetFramePen = new TSolidPen( 10, TPen::kOutsetFrame );
    22  polyBundle->AdoptFramePen( outsetFramePen );
    23  
    24  aPolygon->Draw( thePort );
Lines 1 and 2: An attribute bundle that defines the black frame.

Lines 4 through 7: Create the polygon geometry.

Line 8: Create the polygon graphic from the geometry and the bundle.

Lines 11 and 12: Create a centered pen that is 10 world-coordinate units wide.

Line 14: Draw the polygon.

Lines 16 and 17: Create an inset pen that is 10 world-coordinate units wide.

Line 19: Draw the polygon.

Lines 21 and 22: Create an outset pen that is 10 world-coordinate units wide.

Line 24: Draw the polygon.


[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