1

我想在 SVG 中将填充的正方形彼此相邻放置,但它们之间有细线。如何消除这些线条?

例子:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="3cm" height="3cm" viewBox="0 0 10 10">
    <rect x="0" y="0" width="1" height="1" fill="black" />
    <rect x="2" y="0" width="1" height="1" fill="black" />
    <rect x="4" y="0" width="1" height="1" fill="black" />
    <rect x="6" y="0" width="1" height="1" fill="black" />
    <rect x="8" y="0" width="1" height="1" fill="black" />
    <rect x="0" y="1" width="1" height="1" fill="black" />
    <rect x="2" y="1" width="1" height="1" fill="black" />
    <rect x="3" y="1" width="1" height="1" fill="black" />
    <rect x="4" y="1" width="1" height="1" fill="black" />
    <rect x="5" y="1" width="1" height="1" fill="black" />
    <rect x="6" y="1" width="1" height="1" fill="black" />
    <rect x="7" y="1" width="1" height="1" fill="black" />
    <rect x="9" y="1" width="1" height="1" fill="black" />
    <rect x="0" y="2" width="1" height="1" fill="black" />
    <rect x="2" y="2" width="1" height="1" fill="black" />
    <rect x="8" y="2" width="1" height="1" fill="black" />
    <rect x="0" y="3" width="1" height="1" fill="black" />
    <rect x="1" y="3" width="1" height="1" fill="black" />
    <rect x="3" y="3" width="1" height="1" fill="black" />
    <rect x="5" y="3" width="1" height="1" fill="black" />
    <rect x="6" y="3" width="1" height="1" fill="black" />
    <rect x="8" y="3" width="1" height="1" fill="black" />
    <rect x="9" y="3" width="1" height="1" fill="black" />
    <rect x="0" y="4" width="1" height="1" fill="black" />
    <rect x="1" y="4" width="1" height="1" fill="black" />
    <rect x="5" y="4" width="1" height="1" fill="black" />
    <rect x="6" y="4" width="1" height="1" fill="black" />
    <rect x="8" y="4" width="1" height="1" fill="black" />
    <rect x="0" y="5" width="1" height="1" fill="black" />
    <rect x="3" y="5" width="1" height="1" fill="black" />
    <rect x="4" y="5" width="1" height="1" fill="black" />
    <rect x="9" y="5" width="1" height="1" fill="black" />
    <rect x="0" y="6" width="1" height="1" fill="black" />
    <rect x="5" y="6" width="1" height="1" fill="black" />
    <rect x="6" y="6" width="1" height="1" fill="black" />
    <rect x="8" y="6" width="1" height="1" fill="black" />
    <rect x="0" y="7" width="1" height="1" fill="black" />
    <rect x="4" y="7" width="1" height="1" fill="black" />
    <rect x="5" y="7" width="1" height="1" fill="black" />
    <rect x="6" y="7" width="1" height="1" fill="black" />
    <rect x="8" y="7" width="1" height="1" fill="black" />
    <rect x="9" y="7" width="1" height="1" fill="black" />
    <rect x="0" y="8" width="1" height="1" fill="black" />
    <rect x="1" y="8" width="1" height="1" fill="black" />
    <rect x="2" y="8" width="1" height="1" fill="black" />
    <rect x="7" y="8" width="1" height="1" fill="black" />
    <rect x="8" y="8" width="1" height="1" fill="black" />
    <rect x="0" y="9" width="1" height="1" fill="black" />
    <rect x="1" y="9" width="1" height="1" fill="black" />
    <rect x="2" y="9" width="1" height="1" fill="black" />
    <rect x="3" y="9" width="1" height="1" fill="black" />
    <rect x="4" y="9" width="1" height="1" fill="black" />
    <rect x="5" y="9" width="1" height="1" fill="black" />
    <rect x="6" y="9" width="1" height="1" fill="black" />
    <rect x="7" y="9" width="1" height="1" fill="black" />
    <rect x="8" y="9" width="1" height="1" fill="black" />
    <rect x="9" y="9" width="1" height="1" fill="black" />
</svg>

我的名声不允许我发布图片,但您可以仔细查看我的头像。

4

1 回答 1

5

您在工作中看到了抗锯齿。

将 shape-rendering="crispEdges" 添加到根<svg>元素(或者添加到每个矩形)以获得您想要的显示。

于 2013-04-22T15:52:12.310 回答