【发布时间】:2018-05-13 10:12:27
【问题描述】:
我无法同步涉及缩放和翻译的 SVG 转换。三角形的顶点从点 (967, 491) 平移到 (900, 100),同时 png 图像也应随顶点平移,但也应在移动时按比例缩小或放大。
为了得到 png 图像的原始位置,我正确使用了公式 -centerX*(scale factor - 1), -centerY*(scaleFactor - 1)。这是动画之前的原始位置。但是随着运动的开始,我无法计算它的最终位置。
谁能帮我解决这个问题。
<svg viewBox="0 0 1200 800">
<defs>
<g id="triangle">
<desc>Triangle</desc>
<polygon id="triangle_" points="967,491 738,449 724,603">
<animate attributeName="points" attributeType="XML"
begin="0s" dur="5s" from="967,491 738,449 724,603" to="900,100 738,449 724,603" fill="freeze" />
</polygon>
<g transform="translate(483,245)">
<image xlink:href="http://www.alegralabs.com/human.png" x="940" y="442" width="53" height="98" transform="scale(0.5)" style="fill:#FFF">
<animateTransform attributeName="transform" type="scale" attributeType="XML"
begin="0s" dur="5s" from="0.5" to="0.2" fill="freeze" />
</image>
<animateTransform attributeName="transform" type="translate" attributeType="XML"
begin="0s" dur="5s" to="773,80" fill="freeze" />
<!--<animateMotion from="0,0" to="241,122" dur="5s" fill="freeze" /> -->
</g>
<g>
<text x="940" y="442">1234</text>
<animateMotion from="0,0" to="-67,-391" dur="5s" fill="freeze" />
<g>
</g>
</defs>
<use xlink:href="#triangle" />
</svg>
【问题讨论】:
标签: animation svg synchronization scale translate