GAL: Deal with thick circles
Both Cairo and OpenGL had issues (different, though) with circles that are
thicker in line width than they have radius. This corrects the OpenGL
implementation (radius is calculated to the outer edge) as well as Cairo
(line width needs to be clamped to twice the radius)
Fixes: lp:1822765
* https://bugs.launchpad.net/kicad/+bug/1822765
(cherry picked from commit db0523626c
)
This commit is contained in:
parent
f58844bf8b
commit
c75bd89d63
|
@ -245,6 +245,7 @@ void CAIRO_GAL_BASE::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
|
|||
auto c = roundp( xform( aCenterPoint ) );
|
||||
auto r = ::roundp( xform( aRadius ) );
|
||||
|
||||
cairo_set_line_width( currentContext, std::min( 2.0 * r, lineWidthInPixels ) );
|
||||
cairo_new_sub_path( currentContext );
|
||||
cairo_arc( currentContext, c.x, c.y, r, 0.0, 2 * M_PI );
|
||||
cairo_close_path( currentContext );
|
||||
|
|
|
@ -333,12 +333,11 @@ int isPixelInSegment( vec2 aCoord )
|
|||
|
||||
void strokedCircle( vec2 aCoord, float aRadius, float aWidth )
|
||||
{
|
||||
float outerRadius = max( aRadius + ( aWidth / 2 ), 0.0 );
|
||||
float innerRadius = max( aRadius - ( aWidth / 2 ), 0.0 );
|
||||
float relWidth = innerRadius / outerRadius;
|
||||
float outerRadius = max( aRadius, 0.0 );
|
||||
float innerRadius = max( aRadius - aWidth, 0.0 );
|
||||
|
||||
if( ( dot( aCoord, aCoord ) < 1.0 ) &&
|
||||
( dot( aCoord, aCoord ) > relWidth * relWidth ) )
|
||||
( dot( aCoord, aCoord ) * ( outerRadius * outerRadius ) > innerRadius * innerRadius ) )
|
||||
gl_FragColor = gl_Color;
|
||||
else
|
||||
discard;
|
||||
|
|
Loading…
Reference in New Issue