[英]SVG path want it to render in circular way
I have a path which represent half of the circle, I want it to render in a circular way. 我有一个代表圆形一半的路径,我希望它以圆形方式呈现。
as it is only path I tried of svg but it couldn't work. 因为这只是我尝试过的svg路径,但无法正常工作。
<svg version="1.1" x="0px" y="0px" width="131.45px" height="131.451px" viewBox="0 0 131.45 131.451" enable-background="new 0 0 131.45 131.451" xml:space="preserve"> <g id="Group_952" transform="translate(0 0)"> <g id="Path_211"> <path fill="#0088CE" d="M86.692,128.579l-6.314-20.938c17.843-5.735,29.832-22.563,29.832-41.875 c0-23.389-17.711-42.625-40.314-43.793l1.059-21.9c33.925,1.752,60.5,30.606,60.5,65.69 C131.452,94.733,113.463,119.974,86.692,128.579z"/> </g> <svg>
Your semicircle is drawn using a double path see image below 使用双路径绘制半圆,请参见下图
Therefore, you can animate figure drawing only with the help of filter
or mask
因此,只能在
filter
或mask
的帮助下对图形绘图进行动画处理
I suggest using the technique of drawing a figure from the top point to a semicircle, by changing the 'stroke-dasharray' of the middle line of the figure. 我建议使用通过将图形的中线的“笔划-虚线数组”更改为从顶部到半圆绘制图形的技术。
The middle line turned out - a circle with the center of (70.70)
and a radius of 50
中间线变成-中心为
(70.70)
,半径为50
的圆
Next, set stroke-width ="20"
and stroke-dasharray = "157 157"
to get half the circle 接下来,设置
stroke-width ="20"
和stroke-dasharray = "157 157"
以获得一半的圆
Turn the semicircle counterclockwise 90 degrees so that its beginning is at the top 将半圆逆时针旋转90度,使其起点在顶部
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="131.45px" height="131.451px" viewBox="0 0 131.45 131.451" > <circle transform="rotate(-90 70 70)" cx="70" cy="70" r="50" fill="none" stroke="#0088CE" stroke-width="20" stroke-dasharray="157 157"> </circle> </svg>
To animate the drawing from the top point to half the circle, change the stroke-dasharray
from ="0 314" to ="157 157"
要将绘图从顶部动画到圆的一半,请将
stroke-dasharray
from ="0 314" to ="157 157"
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="131.45px" height="131.451px" viewBox="0 0 131.45 131.451" > <circle transform="rotate(-90 70 70)" cx="70" cy="70" r="50" fill="none" stroke="#0088CE" stroke-width="20" stroke-dasharray="157 157"> <animate attributeName="stroke-dasharray" values="0 314;157 157" dur="5s" fill="freeze" /> </circle> </svg>
.crc1 { fill:none; stroke:#0088CE; stroke-width:20; stroke-dasharray:157.07; animation: dash 4s ; } @keyframes dash { 0% {stroke-dasharray: 0 314} 100% {stroke-dasharray: 157 157} }
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="131.45px" height="131.451px" viewBox="0 0 131.45 131.451" > <circle class="crc1" transform="rotate(-90 70 70)" cx="70" cy="70" r="50"> </circle> </svg>
Semicircle rotation animation 半圆旋转动画
For animation the change of attribute stroke-dashoffset
is used: 对于动画,使用属性
stroke-dashoffset
的更改:
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="131.45px" height="131.451px" viewBox="0 0 131.45 131.451" > <circle cx="70" cy="70" r="50" fill="none" stroke="#EDEDED" stroke-width="20" /> <circle transform="rotate(-90 70 70)" cx="70" cy="70" r="50" fill="none" stroke="#0088CE" stroke-width="20" stroke-dasharray="157.07" stroke-dashoffset="-314"> <animate attributeName="stroke-dashoffset" values="0;-314" dur="2s" repeatCount="indefinite" /> </circle> </svg>
Complex animation of drawing and rotation 绘制和旋转的复杂动画
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="131.45px" height="131.451px" viewBox="0 0 131.45 131.451" > <circle cx="70" cy="70" r="50" fill="none" stroke="#EDEDED" stroke-width="20" /> <circle transform="rotate(-90 70 70)" cx="70" cy="70" r="50" fill="none" stroke="#0088CE" stroke-width="20" stroke-dasharray="157.07" stroke-dashoffset="-314"> <animate id="an_dasharray" attributeName="stroke-dasharray" values="0 314;157 157" begin="0s;an_dashoffset.end+0.5s" dur="2s" fill="freeze" /> <animate id="an_dashoffset" attributeName="stroke-dashoffset" values="0;-314" begin="an_dasharray.end" dur="2s" repeatCount="2" /> </circle> </svg>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.