svg-native-viewer
svg-native-viewer copied to clipboard
Arcs with rx and ry being different are not considered valid
Inside the SVGParserArcToCurve.cpp
on line 109
there is an SVG_ASSERT
that ensures that rx
and ry
are not different. In the event that they are, an assertion is violated, thus the program stops. The comment there says untested
and I think that means the code hasn't been tested for cases where they are different. The correct behavior is for such arcs to be rendered properly.
SVG_ASSERT(angle == 0); // untested
if (radiusX == 0 || radiusY == 0)
{
// this is actually a line
path.LineTo(endX, endY);
return;
}
SVG_ASSERT(radiusX == radiusY); // untested
SVG_ASSERT(radiusX != 0 && radiusY != 0);
I did some testing and it seems that there are problems with Arcs that have a non-zero angle.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2000 1000" width="2000" height="1000">
<path d="M 100,100 a 100 50 -45 0 0 100,0" stroke="red" stroke-width="10" />
<path d="M 100,200 a 100 50 -45 1 0 100,0" stroke="red" stroke-width="10" />
<path d="M 250,100 a 100 50 -45 0 1 100,0" stroke="red" stroke-width="10" />
<path d="M 250,300 a 100 50 -45 1 1 100,0" stroke="red" stroke-width="10" />
<path d="M 500,100 a 100 50 0 0 0 100,0" stroke="red" stroke-width="10" />
<path d="M 500,200 a 100 50 0 1 0 100,0" stroke="red" stroke-width="10" />
<path d="M 650,100 a 100 50 0 0 1 100,0" stroke="red" stroke-width="10" />
<path d="M 750,300 a 100 50 0 1 1 100,0" stroke="red" stroke-width="10" />
<path d="M 100,400 a 100 50 90 0 0 100,0" stroke="red" stroke-width="10" />
<path d="M 100,550 a 100 50 90 1 0 100,0" stroke="red" stroke-width="10" />
<path d="M 250,450 a 100 50 90 0 1 100,0" stroke="red" stroke-width="10" />
<path d="M 250,600 a 100 50 90 1 1 100,0" stroke="red" stroke-width="10" />
<path d="M 740,550 A 100 50 -45 0 0 550,500" stroke="red" stroke-width="10" />
</svg>
Rendering by Librsvg:
Rendering by SNV (Cairo):