okalachev / arucogen

Online ArUco markers generator
http://chev.me/arucogen/
MIT License
413 stars 50 forks source link

Workaround to fix pdf artifacts #13

Closed okalachev closed 2 years ago

okalachev commented 2 years ago

This workaround fixes a long-living issue with exporting the marker to PDF.

Due to peculiarities of PDF rendering on some zoom levels there might appear little gaps between marker's "pixels", that look like this:

Screenshot 2022-03-31 at 03 45 56

I guess, these artifacts might apper on a printed version of marker, which is definitely not good.

SVG's attribute shape-rendering set to crispEdges doesn't save the situation. Changing of any related SVG parameter's doesn't help as well.

This patch implements a workaround for this. For each white pixel of a marker, if there is a white pixel on the right, the width of the pixel is increased to 1.5 to overlap potential gap.

If there is a white pixel under it, another white rect is added with height 1.5 to overlap the gap as well.

Thus, the rendered PDF is guaranteed to not have such artifacts:

Screenshot 2022-03-31 at 03 45 58