如何分割svg矩形?

问题描述 投票:0回答:1

我正在尝试分割矩形,以便应平均分割。我也不知道是否可以拆分svg矩形?

这是svg代码:

<rect x="29" y="239" width="200" height="80" r="8" rx="8" ry="8" fill="#006699" stroke="#337ab7" style="cursor: pointer;" stroke-width="1" transform="matrix(1,0,0,1,0,-120)"></rect>

<text style="text-anchor: middle; font: 13px &quot;Arial&quot;; cursor: pointer;" x="129" y="279" text-anchor="middle" font="10px &quot;Arial&quot;" stroke="none" fill="#ffffff" font-size="13px" transform="matrix(1,0,0,1,0,-120)"><tspan dy="4.5">one</tspan></text>

输出:

enter image description here

但是我正在尝试那样创建:

enter image description here

我已遵循本教程:

https://www.w3schools.com/graphics/svg_rect.asp

这是我尝试解决的另一个文档,但没有帮助:

https://www.w3.org/TR/SVG/painting.html#FillRuleProperty

其他教程:

https://flaviocopes.com/svg/#path

javascript svg rectangles
1个回答
0
投票

如果在每个过渡点使用多个光阑来创建即时过渡,则可以使用linearGradient显示多种颜色。

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 50 300 300">

    <defs>
      <linearGradient id="MyGradient" x2="0%" y2="100%">
        <stop offset="50%" stop-color="green" />
        <stop offset="50%" stop-color="white" />
      </linearGradient>
    </defs>
<rect x="29" y="239" width="200" height="80" r="8" rx="8" ry="8" fill="url(#MyGradient)" stroke="#337ab7" style="cursor: pointer;" stroke-width="1" transform="matrix(1,0,0,1,0,-120)"></rect>

<text style="text-anchor: middle; font: 13px 'Arial' cursor: pointer;" x="129" y="279" text-anchor="middle" font="10px &quot;Arial&quot;" fill="#ffffff" font-size="13px" transform="matrix(1,0,0,1,0,-140)"><tspan dy="4.5">one</tspan></text>
<text style="text-anchor: middle; font: 13px 'Arial' cursor: pointer;" x="129" y="279" text-anchor="middle" font="10px &quot;Arial&quot;" fill="black" font-size="13px" transform="matrix(1,0,0,1,0,-100)"><tspan dy="4.5">one</tspan></text>

</svg>
© www.soinside.com 2019 - 2024. All rights reserved.