我有一个 SVG 文件包含大约 20000 个路径,如下所示:
<rect x="0" y="0" fill="#191915" width="1" height="1"/>
<rect x="0" y="1" fill="#191915" width="1" height="1"/>
<rect x="0" y="2" fill="#191915" width="1" height="1"/>
<rect x="0" y="3" fill="#191915" width="1" height="1"/>
<rect x="0" y="4" fill="#191915" width="1" height="1"/>
<rect x="0" y="5" fill="#191915" width="1" height="1"/>
<rect x="0" y="6" fill="#191915" width="1" height="1"/>
<rect x="0" y="7" fill="#FF00FF" width="1" height="1"/>
<rect x="0" y="8" fill="#191915" width="1" height="1"/>
<rect x="0" y="9" fill="#191915" width="1" height="1"/>
<rect x="0" y="10" fill="#191915" width="1" height="1"/>
<rect x="0" y="11" fill="#191915" width="1" height="1"/>
<rect x="0" y="12" fill="#191915" width="1" height="1"/>
ETC...
每个标签都包含路径的位置、颜色填充以及它的宽度和高度(始终为 1 像素)我需要一个工具来自动将相似的连接标签彼此合并为一个标签,例如:
<polygon fill="#191915" points="0,0 0,1 0,2 0,3 0,4 0,5 0,6 1.6 1.5 1.4 1.3 1.2 1.1 1.0"\>
<rect x="0" y="6" fill="#FF00FF" width="1" height="1"/>
<polygon fill="#191915" points="0.8 0.9 0.10 0.11 0.12 1.12 1.11 1.10 1.9 1.8"\>