nanosvg
nanosvg copied to clipboard
Circle from two arcs not rendering properly
The path below should render as a circle, but NSVG returns only the lower half (twice). Probably a numerical error somewhere in arc calculations.
The path is a part of an actual file made with Inkscape, Qt, Firefox, etc. render it properly. The whole file validates with the w3c validator.
<path
sodipodi:type="arc"
style="fill:#000000;fill-opacity:0;stroke:#000000;stroke-width:10.70246888;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path4687-1"
sodipodi:cx="330.72961"
sodipodi:cy="426.55115"
sodipodi:rx="33.07296"
sodipodi:ry="34.451"
d="m 363.80257,426.55115 a 33.07296,34.451 0 1 1 -66.14592,0 33.07296,34.451 0 1 1 66.14592,0 z"
transform="matrix(2.892314,0,0,2.7166215,-388.8214,-747.3853)" />
I'm going through the nsvg__pathArcTo
right now, will provide a patch if I find anything. Here is the list of points I get from NSVG: http://pastebin.com/UdgnMnqU (split in groups of for as in the example from README).
Referring to code from commit a523e0215f3f99d44b2dcfdf241e0e27a75e35f0 I got this working by:
- Changing all
nsvg__pathArcTo
float variables exceptx
,y
,tanx
,tany
,t[6]
to double - Changing all calls to c library to use the double version
- In line 2066 change
if (da > 0.0f)
toif (da >= 0.0f)
- Similarly in line
if (da < 0.0f)
toif (da <= 0.0f)
I don't know which change exactly fixed the issue and don't really have the time to experiment atm.
For reference I'm using MinGW 4.9.2 bundled with Qt 5.5.0 (yes, this is a Qt project).
Please check #88 or the current master code that included the fix. If it's ok, please close this bug.