gpt4 book ai didi

SVG animateTransform 翻译和缩放同时失败

转载 作者:行者123 更新时间:2023-12-04 01:46:11 27 4
gpt4 key购买 nike

我有一条路径要使用 animateTransform 设置动画.我想同时翻译和缩放路径。它不起作用。显然只有第二个动画在工作:在这种情况下 scale .我究竟做错了什么?

svg{
width:300px;
border:1px solid;
fill:none;
stroke:black;
}
<svg viewBox="-100 -100 200 200">

<path d="M-36.911,0C-36.911,-19.833,-19.833,-35.911,0,-35.911C19.833,-35.911,35.911,-19.833,35.911,0C35.911,19.833,19.833,35.911,0,35.911C-19.833,35.911,-36.911,19.833,-36.911,0z">

<animateTransform
attributeType="xml"
attributeName="transform"
type="translate"
dur="5s"
values="0,0; 0,-50; 0,0; 0,50;0,0"
repeatCount="indefinite"/>
<animateTransform
attributeType="xml"
attributeName="transform"
type="scale"
dur='5s'
values="1;1.2;1;1.2;1"
repeatCount="indefinite"/>

</path>

<circle r="1" />
</svg>

最佳答案

第二个转换需要是 additive="sum"这样它就不会取代第一个。

svg{
width:300px;
border:1px solid;
fill:none;
stroke:black;
}
<svg viewBox="-100 -100 200 200">

<path d="M-36.911,0C-36.911,-19.833,-19.833,-35.911,0,-35.911C19.833,-35.911,35.911,-19.833,35.911,0C35.911,19.833,19.833,35.911,0,35.911C-19.833,35.911,-36.911,19.833,-36.911,0z">

<animateTransform
attributeType="xml"
attributeName="transform"
type="translate"
dur="5s"
values="0,0; 0,-50; 0,0; 0,50;0,0"
repeatCount="indefinite"/>
<animateTransform
attributeType="xml"
attributeName="transform"
type="scale"
dur='5s'
values="1;1.2;1;1.2;1"
repeatCount="indefinite"
additive="sum"/>

</path>

<circle r="1" />
</svg>

关于SVG animateTransform 翻译和缩放同时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55199311/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com