What would you want from a high-level SVG wrapper package?

Yeah, I know exactly what you’re talking about! I’ve certainly used the “offset by 0.5 pixels” trick myself to get sharp lines. It’s a really good point - I’ll have to think about it a bit more, but there may be things that elm-2d-drawing can do to help there.

There could potentially be something like a snapToNearestPixel attribute that would be result in a ‘best effort’ attempt to get pixel-aligned lines (taking current stroke width into account). For a lot of common cases (horizontal or vertical lines, axis-aligned rectangles) that should work fine, but there would be some caveats:

  • Wouldn’t work with angled/curved lines (maybe could work with 45 degree lines as a special case?)
  • Wouldn’t work if you transformed the geometry after creating it, unless the transformation was something like translation by integer numbers of pixels. I guess that if the attribute was set, then translation transformations could themselves be snapped to integer numbers of pixels to ensure that they didn’t mess up sharp lines…and maybe rotations that happen to be multiples of 90 degrees could have the rotation center point snapped to a pixel boundary as well.

Alternatively, there could simply be some special draw functions like snappedVerticalLine, snappedHorizontalLine and snappedRectangle that could be restricted to accept axis-aligned stuff and document that the arguments will be snapped to create sharp lines.