[英]How to animate entire “path” element of svg?
I have read this documentation http://www.w3.org/TR/SVG/animate.html about svg animation and i know how to animate rectangle,circle etc,but this document doesn't contains any info on how to animate entire svg "path" element. 我已经阅读了有关svg动画的文档http://www.w3.org/TR/SVG/animate.html ,并且我知道如何为矩形,圆形等设置动画,但是该文档不包含有关如何为整个动画设置动画的信息svg“路径”元素。
I am creating bow and arrow game and i want to animate the "path" element to the right when user clicks on a button. 我正在创建弓箭游戏,当用户单击按钮时,我想为右侧的“路径”元素设置动画。 i just want to know how to animate entire "path" element?? 我只想知道如何为整个“路径”元素设置动画?
In the below code i want to animate second "path" element to the right... 在下面的代码中,我想为右边的第二个“路径”元素设置动画。
<svg width="500" height="500">
<path d="M150,150 l0,150 q80,-50 0,-150 M220,230 l-120,0 m120,0 l-20,10 m20,-10 l-20,-10" style="stroke:black;stroke-width:5;fill:red;"/>
<path d="M220,230 l-120,0 m120,0 l-20,10 m20,-10 l-20,-10" style="stroke:orange;width:5" />
</svg>
After some trail and error i finally resolve my issue.Below is the code for the same. 经过一番周折后,我终于解决了我的问题。下面是相同的代码。
<svg width="500" height="500">
<path d="M150,150 l0,150 q80,-50 0,-150 M220,230 l-120,0 m120,0 l-20,10 m20,-10 l-20,-10" style="stroke:black;stroke-width:5;fill:red;"/>
<path d="M220,230 l-120,0 m120,0 l-20,10 m20,-10 l-20,-10" style="stroke:orange;width:5">
<animateMotion
path="M0,0 l300,0"
begin="0s" dur="5s" repeatCount="1"
/>
</path>
</svg>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.