简体   繁体   English

Python svgwrite 和同步动画转换

[英]Python svgwrite and simultaneous animationTransforms

I am trying to use python svgwrite to make an object scale and rotate at the same time.我正在尝试使用 python svgwrite 来制作 object 缩放并同时旋转。 My efforts has so far been to add two consecutive "animateTransform".到目前为止,我的努力是添加两个连续的“animateTransform”。 It does however seem to only take the last action into account, as seen in my example.然而,它似乎只考虑了最后一个动作,如我的示例所示。

import svgwrite 

path = [(100,100),(100,200),(200,200),(200,100)]

image = svgwrite.Drawing('test.svg',size=(300,300))

rectangle = image.add(image.polygon(path,id ='polygon',stroke="black",fill="white"))
rectangle.add(image.animateTransform("rotate","transform",id="polygon", from_="0 150 150", to="360 150 150",dur="4s",begin="0s",repeatCount="indefinite"))
rectangle.add(image.animateTransform("scale","transform",id="polygon", from_="0", to="1",dur="4s",begin="0s",repeatCount="indefinite"))

image.save()
display(SVG('test.svg'))

Can anyone help?任何人都可以帮忙吗?

This maybe comes too late, but what worked for me is adding additive = "sum" to both animations.这可能来得太晚了,但对我有用的是在两个动画中添加additive = "sum" Be aware that the order in which you add the animations impacts the end result.请注意,添加动画的顺序会影响最终结果。

import svgwrite 

path = [(100,100),(100,200),(200,200),(200,100)]

image = svgwrite.Drawing('test.svg',size=(300,300))

rectangle = image.add(image.polygon(path,id ='polygon',stroke="black",fill="white"))
rectangle.add(image.animateTransform("scale","transform",id="polygon", from_="0", to="1",dur="4s",begin="0s",repeatCount="indefinite", additive = "sum"))    
rectangle.add(image.animateTransform("rotate","transform",id="polygon", from_="0 150 150", to="360 150 150",dur="4s",begin="0s", additive = "sum", repeatCount="indefinite"))

image.save()
display(SVG('test.svg'))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM