Ilya Zakharevich on Wed, 18 Dec 2019 08:39:24 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PATCH v2.11.1] High-resolution PS plotting |
On Mon, Nov 11, 2019 at 11:35:42PM -0800, Ilya Zakharevich wrote: > It looks like the low-precision problem is avoided with SVG, due to (≈l.2088) > > gen_draw(&pl, w, x, y, SVG_SCALE, SVG_SCALE); > > (Only 1/SVG_SCALE = 2⁻¹⁰ is later rounded by "%.2f"; I see no reason > for such a strange code…) A bit more clarification on the strangeness of the code: • The coordinates are initially stored (inside the “rectangles”) as floating point; • Then SVG code in rect2svg() asks to scale it up 1024 times (still to floats); • Then gen_draw() converts it to integers to pass to the low-level (format-specific) engine; • Then every low-level entry point (such as svg_lines()) scales these coordinates DOWN 1024 times (to floats); • Then these coordinates are str_printf()ed with "%.2f"). Seems like whoever wrote SVG engine realized the problem with low-level entry points taking integer values — but instead of converting the API to behave sensibly they put in this mess with scaling up/down (with the coefficient incompatible with the printf-format!). (This mess with integer coefficients is most probably MY fault! Myself, I wanted to convert all the low-level API to “double”s for more than a decade! — These functions are statics anyway!) Hope this helps, Ilya