gpt4 book ai didi

javascript - SVG TextPath 文本显示颠倒

转载 作者:行者123 更新时间:2023-11-29 18:44:38 24 4
gpt4 key购买 nike

下面是 SVG 代码,将路径上的文本倒置显示。请帮助展示如何正确显示它。

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" xml:space="preserve">
<g>
<path id="link1" d="M 500,140 C 200,140 200,190 500,190" stroke-width="20" fill="transparent" stroke="red"></path>
<text class="text_path">
<textPath xlink:href="#link1" startOffset="10">
<tspan dy="5">Some Text</tspan><tspan class="dir_arrow">→</tspan>
</textPath>
</text>
</g>
</svg>

最佳答案

因为您是从下到上绘制曲线,所以文本遵循绘制曲线的方向并且是“上下颠倒”的。

如果您想要反方向的文本,则需要从上到下绘制曲线,以便绘图的方向与您想要的文本的方向相匹配。

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="600px" height="600px">
<g>
<path id="link1" d="M 500,190 C 200,190 200,140 500,140" stroke-width="20" fill="transparent" stroke="red"></path>
<text class="text_path">
<textPath xlink:href="#link1" startOffset="370">
<tspan dy="5" class="dir_arrow">←</tspan><tspan>Some Text</tspan>
</textPath>
</text>
</g>
</svg>

关于javascript - SVG TextPath 文本显示颠倒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54798470/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com