pcbnew: SVG importer support for even-odd fill rule

This commit is contained in:
Tomasz Wlostowski 2021-12-30 03:48:44 +01:00
parent 5d87b37f52
commit e1f32f13a2
1 changed files with 12 additions and 1 deletions

View File

@ -76,6 +76,17 @@ bool SVG_IMPORT_PLUGIN::Import()
{
double lineWidth = shape->strokeWidth;
GRAPHICS_IMPORTER::POLY_FILL_RULE rule = GRAPHICS_IMPORTER::PF_NONZERO;
switch( shape->fillRule )
{
case NSVG_FILLRULE_NONZERO: rule = GRAPHICS_IMPORTER::PF_NONZERO; break;
case NSVG_FILLRULE_EVENODD: rule = GRAPHICS_IMPORTER::PF_EVEN_ODD; break;
default: break;
}
m_importer->NewShape( rule );
for( NSVGpath* path = shape->paths; path != nullptr; path = path->next )
DrawPath( path->pts, path->npts, path->closed, shape->fill.type == NSVG_PAINT_COLOR,
lineWidth );
@ -117,7 +128,7 @@ void SVG_IMPORT_PLUGIN::DrawPath( const float* aPoints, int aNumPoints, bool aCl
if( aNumPoints > 0 )
DrawCubicBezierPath( aPoints, aNumPoints, collectedPathPoints );
if( aFilled && aClosedPath )
if( aFilled )
DrawPolygon( collectedPathPoints, aLineWidth );
else
DrawLineSegments( collectedPathPoints, aLineWidth );