memononen / nanosvg

Simple stupid SVG parser
zlib License
1.71k stars 363 forks source link

Bug in ArcTo code #88

Closed X-Ryl669 closed 7 years ago

X-Ryl669 commented 7 years ago

If following the W3 specification here: https://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes , the code: https://github.com/memononen/nanosvg/blob/master/src/nanosvg.h#L2082 is likely wrong, since fa is checked (should be fs). See Step 4 in section F.6.5 that says:

In other words, if fS = 0 and the right side of (F.6.5.6) is greater than 0, then subtract 360°, whereas if fS = 1 and the right side of (F.6.5.6) is less than 0, then add 360°. In all other cases leave it as is.

The code should read around something like this:

    if (fs == 0 && da > 0) 
         da -= 2 * NSVG_PI;
    else if (fs == 1 && da < 0)
         da += 2 * NSVG_PI;
Cultrarius commented 7 years ago

Nice find!

memononen commented 7 years ago

Good catch, I merged the fix.