SVG pattern animation

安稳与你 提交于 2019-12-11 01:18:58

问题


I have defined a pattern in svg. I want to rotate it continuously.... I'm not able to apply animation on that pattern definition. i applied same animation to a symbol , it works but its not working on pattern...

<pattern id="GPattern"
         x="10" y="10" width="20" height="20"
         patternUnits="userSpaceOnUse"
         patternTransform="rotate(35)"
        >
        <circle id="mycircle" cx="10" cy="10" r="10" style="stroke: none; fill: red" > </circle>
     </pattern>

this is pattern def.

Please help me how i can apply certain transform animation to whole "pattern" as well as to individual contents of it.. in this case circle...


回答1:


There doesn't seem to be anything stopping you dropping an <animateTransform> into the pattern definition:

<svg width="200" height="200" viewBox="0 0 200 200">
  <defs>
    <pattern id="GPattern" x="10" y="10" width="20" height="20"
             patternUnits="userSpaceOnUse"
             patternTransform="rotate(35)">
      <animateTransform attributeType="xml"
                        attributeName="patternTransform"
                        type="rotate" from="35" to="395" begin="0"
                        dur="60s" repeatCount="indefinite"/>
      <circle cx="10" cy="10" r="10" stroke="none" fill="red"/>
    </pattern>
  </defs>
  <rect x="0" y="0" width="200" height="200" fill="url(#GPattern)"/>
</svg>


来源:https://stackoverflow.com/questions/32858120/svg-pattern-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!