Avoiding lines between adjecent svg rectangles

后端 未结 1 786
北海茫月
北海茫月 2020-12-03 09:19

Although there\'s some standardized options for hinting the browser about anti-aliasing in svg, none of them seems to work for my case where I have rectangles with rounded c

相关标签:
1条回答
  • 2020-12-03 09:43

    two hardware vertical pixels per software exposed pixel

    No that's wrong.

    When you specify a coordinate like "81" in an SVG, that coordinate falls on the imaginary line between pixel 80 and 81. If your line has width "1", then the renderer will attempt to draw that by placing 50% of the colour on the 80 pixel and 50% on the 81 pixel. This is anti-aliasing. If you want the one pixel line to not be anti-aliased like that, give it coordinate 81.5. That way the whole line will fall within pixel 81.

    However if your line had width 2 (or any other even width) you should not use 81.5 but stay with 81. Because it will render 50% (ie. 1) in pixel 80 and 50% (1) in pixel 81. Resulting in no anti-aliasing effect.

    enter image description here

    This applies for both horizontal and vertical lines. And applies whether you are on an LCD or old CRT.

    Does this explanation make sense now?

    0 讨论(0)
提交回复
热议问题