nanosvg icon indicating copy to clipboard operation
nanosvg copied to clipboard

Circle from two arcs not rendering properly

Open jaskij opened this issue 8 years ago • 2 comments

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).

jaskij avatar Mar 12 '16 16:03 jaskij

Referring to code from commit a523e0215f3f99d44b2dcfdf241e0e27a75e35f0 I got this working by:

  1. Changing all nsvg__pathArcTo float variables except x, y, tanx, tany, t[6] to double
  2. Changing all calls to c library to use the double version
  3. In line 2066 change if (da > 0.0f) to if (da >= 0.0f)
  4. Similarly in line if (da < 0.0f) to if (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).

jaskij avatar Mar 12 '16 18:03 jaskij

Please check #88 or the current master code that included the fix. If it's ok, please close this bug.

X-Ryl669 avatar Jun 06 '17 11:06 X-Ryl669