【发布时间】:2018-04-02 23:54:12
【问题描述】:
使用 SVG,我正在尝试复制小提琴的琴弦 - 它们是如何向螺母末端逐渐变细的。我希望我可以使用变换来做到这一点(因为我有其他复杂的形状并且想保持统一的逻辑坐标)。但我不确定转换应该是什么。
基本上,我希望最左边的 Y 坐标缩放 0.66,而在最右边,不缩放 (1.0)。
(在我下面的示例中,Y 中心线为 32.5)。
<p>This is how I want it to look:</p>
<svg width="500" height="60">
<g stroke-width="1" stroke="black">
<line x1="10" y1="17.5" x2="490" y2="10"/>
<line x1="10" y1="27.5" x2="490" y2="25" />
<line x1="10" y1="37.5" x2="490" y2="40"/>
<line x1="10" y1="47.5" x2="490" y2="55"/>
</g>
</svg>
<p>But I want to accomplish it by using a transform on the group element below.</p>
<svg width="500" height="60">
<g transform="??????" stroke-width="1" stroke="black">
<line x1="10" y1="10" x2="490" y2="10"/>
<line x1="10" y1="25" x2="490" y2="25" />
<line x1="10" y1="40" x2="490" y2="40"/>
<line x1="10" y1="55" x2="490" y2="55"/>
</g>
</svg>
【问题讨论】:
-
我不认为你可以用一个单一的 svg 转换来做到这一点。从您的描述中,我真的不明白为什么需要这样做。
-
SVG 不支持非仿射变换。您可以尝试 CSS 3d 变换,但这会使线条在一端变细。