
Quadratic curve with TGPoint
This code fragment draws a quadratic curve that has 3 control points and an order of 3. This curve is shown in the top-left corner of Figure 45.
TGCurve aQuadraticCurve( TGPoint( 25, 25 ),
TGPoint( 45, 100 ),
TGPoint( 95, 75 ) );
TFrameBundle aBundle( TRGBColor( 0, 0, 0), 5.0 );
thePort.Draw( aQuadraticCurve, aBundle );
TGCurve aCubicCurve( TGPoint( 25, 125 ),
TGPoint( 45, 200 ),
TGPoint( 95, 175 ),
TGPoint( 70, 150 ) );
TFrameBundle aBundle( TRGBColor( 0, 0, 0), 5.0 );
thePort.Draw( aCubicCurve, aBundle );
static const TGRPoint curvePointArray[ 4 ] = {
TGRPoint( 175, 25, 1 ),
TGRPoint( 195, 100, 1 ),
TGRPoint( 245, 75, 1 ),
TGRPoint( 220, 50, 1 )
};
TGRPointArray aCurveArray( 4 );
for( long m = 0; m < 4; m++ )
aCurveArray.SetPoint( m, curvePointArray[ m ] );
TGCurve aGeneralCurve( 4, aCurveArray );
TFrameBundle aBundle( TRGBColor( 0, 0, 0), 5.0 );
thePort.Draw( aGeneralCurve, aBundle );
static const TGRPoint curvePointArray2[ 7 ] = {
TGRPoint( 175, 125, 1 ),
TGRPoint( 195, 200, 1 ),
TGRPoint( 245, 175, 1 ),
TGRPoint( 220, 150, 1 ),
TGRPoint( 250, 150, 1 ),
TGRPoint( 275, 100, 1 ),
TGRPoint( 260, 50, 1 )
};
TGRPointArray aCurveArray2( 4 );
for( long n = 0; n < 4; n++ )
aCurveArray2.SetPoint( n, curvePointArray2[ n ] );
static const GCoordinate knotArray[ 10 ] = {
( 0 ), ( 0 ), ( 0 ), ( 1 ), ( 1 ),
( 2 ), ( 2 ), ( 3 ), ( 3 ), ( 3 )
};
TRawArray< GParametric > knots( 10);
for( long o = 0; o < 10; o++ )
knots.SetValue( o, knotArray[ o ] );
TGCurve aGeneralCurve2( 3, aCurveArray2, knots );
TFrameBundle aBundle( TRGBColor( 0, 0, 0), 5.0 );
thePort.Draw( aGeneralCurve2, aBundle );