在Inkscape中有没有一个命令可以将路径的坐标四舍五入为最接近的整数值。
例如,要替换此路径:
m 0,0 261.98828,-890.8828 -299.999999,-900 2593.486319,54.4063 -253.9941,850.09565 264.3594,870.83005 z
通过这个:
m 0,0 262,-891 -300,-900 2593,54 -254,850 264,871 z
在Inkscape中有没有一个命令可以将路径的坐标四舍五入为最接近的整数值。
例如,要替换此路径:
m 0,0 261.98828,-890.8828 -299.999999,-900 2593.486319,54.4063 -253.9941,850.09565 264.3594,870.83005 z
通过这个:
m 0,0 262,-891 -300,-900 2593,54 -254,850 264,871 z
是的,有一种方法可以设置坐标精度。
setTimeout(() => {
document.querySelectorAll('path').forEach((p) => {
p.setAttribute(
'd',
p.getAttribute('d')
.split(/(\d*\.?\d*)/g)
.map((e) => {
return isNaN(parseFloat(e)) ?
e :
Math.round(parseFloat(e), 0)
}).join(''))
})
}, 2000)
html,
body {
margin: 0;
height: 100vh;
overflow: hidden;
}
<svg viewBox="0 0 50 30" height="100%">
<g fill="none">
<circle cx="5" cy="21" r="1" stroke="green" stroke-width=".5" />
<circle cx="43" cy="6" r="1" stroke="green" stroke-width=".5" />
<circle cx="35" cy="24" r="1" stroke="green" stroke-width=".5" />
<path
stroke="red"
d="
M 5.4131 20.555
L 43.345 5.666
L 34.822 24.22222
Z"
stroke-width=".5"
/>
</g>
</svg>