Example arbitrary area

This code fragment creates the arbitrary area shown in Figure 64. This area is similar to the area described under the heading "Creating an Area" on page 104.


    1  TGRect aRectangle( 50, 50, 100, 80 );
    2  TGArea anArea( aRectangle );
    3  
    4  TGEllipse anEllipse( TGRect( 70, 70, 90, 90 ) );
    5  anArea += TGArea( anEllipse );
    6  
    7  TGPolygon aPolygonGeometry;
    8  aPolygonGeometry.Append( TGPoint( 135, 105 ) );
    9  aPolygonGeometry.Append( TGPoint( 100, 75 ) );
    10  aPolygonGeometry.Append( TGPoint( 80, 75 );
    11  aPolygonGeometry.Append( TGPoint( 105, 105 );
    12  aPolygonGeometry.Append( TGPoint( 130, 55 ) );
    13  
    14  anArea -= ( aPolygon );
    15  
    16  TFillAndFrameBundle aBundle( TRGBColor( .75, .5, .5 ),TRGBColor( 0, 0, 0 ), 5.0 );
    17  ThePort.Draw( anArea, aBundle );
Lines 1 and 2: Create a rectangle geometry and use it to create an area geometry.

Lines 4 and 5: Create an ellipse geometry and add it to the area geometry.

Lines 7 through 12: Create a polygon geometry.

Line 14: Subtract the polygon from the area geometry.

Line 16 : Create an attribute bundle with fill, frame, and pen styles.

Line 17: Send the area and the bundle to the drawing port.


[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