Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Animation SVG从中心点而不是左上角缩放动画_Animation_Svg_Svg Animate - Fatal编程技术网

Animation SVG从中心点而不是左上角缩放动画

Animation SVG从中心点而不是左上角缩放动画,animation,svg,svg-animate,Animation,Svg,Svg Animate,如何在SVG中使用animateTransform从中心点而不是左上角缩放对象 例如: <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100px" height="100px"> <circle style="fill:blue;" cx="50" cy="50" r="45"> <

如何在SVG中使用
animateTransform
从中心点而不是左上角缩放对象

例如:

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100px" height="100px">
    <circle style="fill:blue;" cx="50" cy="50" r="45">
        <animateTransform attributeName="transform"
             type="scale"
             from="0 0"
             to="1 1"
             begin="0s"
             dur="1s"
             repeatCount="indefinite"
        />
    </circle>
</svg>

)


将缩放变换更改为使用
additional=“sum”
并应用将圆转换为图像中心的附加变换。因此,与其在图像中心定义形状,不如将其中心定义为
0
,然后使用
transform
属性将其转换为
50,50
(特定图像的确切中心)


非常感谢你!!这么简单。如果它不是一个圆,例如一条复杂的路径,你如何定义它在中心?只需计算准确的中心点,然后移动到那里,然后移动到真正的开始位置?
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100px" height="100px">
    <circle style="fill:blue;" cx="0" cy="0" r="45" transform="translate(50 50)">
        <animateTransform attributeName="transform"
             type="scale"
             additive="sum" 
             from="0 0"
             to="1 1"
             begin="0s"
             dur="1s"
             repeatCount="indefinite"
        />
    </circle>
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100px" height="100px">
    <defs>
        <circle id="def-circle" style="fill:blue;" cx="0" cy="0" r="45" />
    </defs>

    <use xlink:href="#def-circle" transform="translate(50 50)">
        <animateTransform attributeName="transform" 
        type="scale"
        additive="sum"    
        from="0 0"
        to="1 1"      
        beg="0s"
        dur="1s"
        repeatCount="indefinite" />
    </use>   
</svg>