Commit 490a73b6 authored by Maciej Suminski's avatar Maciej Suminski

Fixed filled arcs drawing (GAL).

parent bcdd3d7b
...@@ -223,6 +223,19 @@ void CAIRO_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aS ...@@ -223,6 +223,19 @@ void CAIRO_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aS
cairo_new_sub_path( currentContext ); cairo_new_sub_path( currentContext );
cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle ); cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
if( isFillEnabled )
{
VECTOR2D startPoint( cos( aStartAngle ) * aRadius + aCenterPoint.x,
sin( aStartAngle ) * aRadius + aCenterPoint.y );
VECTOR2D endPoint( cos( aEndAngle ) * aRadius + aCenterPoint.x,
sin( aEndAngle ) * aRadius + aCenterPoint.y );
cairo_move_to( currentContext, aCenterPoint.x, aCenterPoint.y );
cairo_line_to( currentContext, startPoint.x, startPoint.y );
cairo_line_to( currentContext, endPoint.x, endPoint.y );
cairo_close_path( currentContext );
}
isElementAdded = true; isElementAdded = true;
} }
......
...@@ -377,17 +377,12 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a ...@@ -377,17 +377,12 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
// Swap the angles, if start angle is greater than end angle // Swap the angles, if start angle is greater than end angle
SWAP( aStartAngle, >, aEndAngle ); SWAP( aStartAngle, >, aEndAngle );
VECTOR2D startPoint( cos( aStartAngle ), sin( aStartAngle ) );
VECTOR2D endPoint( cos( aEndAngle ), sin( aEndAngle ) );
VECTOR2D startEndPoint = startPoint + endPoint;
VECTOR2D middlePoint = 0.5 * startEndPoint;
Save(); Save();
currentManager->Translate( aCenterPoint.x, aCenterPoint.y, layerDepth ); currentManager->Translate( aCenterPoint.x, aCenterPoint.y, layerDepth );
if( isStrokeEnabled ) if( isStrokeEnabled )
{ {
double alphaIncrement = 2.0 * M_PI / CIRCLE_POINTS; const double alphaIncrement = 2.0 * M_PI / CIRCLE_POINTS;
currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
VECTOR2D p( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius ); VECTOR2D p( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius );
...@@ -411,20 +406,24 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a ...@@ -411,20 +406,24 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
if( isFillEnabled ) if( isFillEnabled )
{ {
double alphaIncrement = 2 * M_PI / CIRCLE_POINTS; const double alphaIncrement = 2 * M_PI / CIRCLE_POINTS;
double alpha; double alpha;
currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a );
currentManager->Shader( SHADER_NONE );
// Triangle fan
for( alpha = aStartAngle; ( alpha + alphaIncrement ) < aEndAngle; ) for( alpha = aStartAngle; ( alpha + alphaIncrement ) < aEndAngle; )
{ {
currentManager->Vertex( middlePoint.x, middlePoint.y, 0.0 ); currentManager->Vertex( 0.0, 0.0, 0.0 );
currentManager->Vertex( cos( alpha ), sin( alpha ), 0.0 ); currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, 0.0 );
alpha += alphaIncrement; alpha += alphaIncrement;
currentManager->Vertex( cos( alpha ), sin( alpha ), 0.0 ); currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, 0.0 );
} }
currentManager->Vertex( middlePoint.x, middlePoint.y, 0.0 ); // The last missing triangle
currentManager->Vertex( cos( alpha ), sin( alpha ), 0.0 ); const VECTOR2D endPoint( cos( aEndAngle ) * aRadius, sin( aEndAngle ) * aRadius );
currentManager->Vertex( 0.0, 0.0, 0.0 );
currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, 0.0 );
currentManager->Vertex( endPoint.x, endPoint.y, 0.0 ); currentManager->Vertex( endPoint.x, endPoint.y, 0.0 );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment