On 11 June 2018 at 20:19, chris wrote:
> I have found another "trial and error change" in nanosvgrast.h, that
> seems to removes all these issues completely:
>
> Just change the #define NSVG_FIXSHIFT (nanosvgrast.h line 92) from 10 to 14.
>
> No more wobbling and a perfect rounded cap all along the circle.
>
> But don't ask me why..
Well, it's a fixed-point number system, using integer maths: By
default they are using a shift of 10 bits, so assuming we are using a
32-bit integer (which seems like a safe assumption for now...) then we
have (setting aside the effect of sign bits etc) effectively 22-bits
of "integer" part and 10-bits of "fractional" part. (Or, 21-bits of
usable integer range, plus the sign bit...)
By setting FIXSHIFT larger, you are making for more resolution in the
fractional part, but at the cost of less range in the integral part -
something like 17-bits of integral range (plus the sign.)
Now, 17-bits of integral range might well be enough for a lot of
pictures, so maybe that is OK?
In any case, it seems like the additional fractional resolution
improves things in your test (I have not actually tried this test...)
and it does seem, intuitively, that improved fractional resolution
would help with the problem as reported.
Did it need to be as high as 14-bits for the fractional part? I'd
expect to see some improvement for each bit added to the fraction - in
effect each bit added to the fractional resolution ought to (roughly)
half the size of the rounding error (assuming rounding error is the
source of the problem, of course!)