SVG - 从中​​心开始缩放圆圈

use*_*r10 7 svg

我想缩放嵌入在svg中的弧线.在应用比例变换时,它会向0,0缩放.相反,我希望它可以从它自己的缩放中心缩放.

这是代码

<g>                 
    <path d="M 300 100 a 200 200 0 1 0 0.00001 0" fill="#7EEC4A" stroke="rgb(208,231,235)" linejoin="round" stroke-width="1" fill-opacity="0.9" stroke-opacity="0.2">
    </path>

    <animateTransform attributeType="xml"
        attributeName="transform"
        type="scale"
        from="0"
        to="1"
        dur="0.5s" fill="freeze" />
</g>
Run Code Online (Sandbox Code Playgroud)

mbo*_*nin 12

使用<circle>元素并设置"r"属性的动画:

<g>                 
    <circle cx="200" cy="200" r="200" fill="#7EEC4A" stroke="rgb(208,231,235)" linejoin="round" stroke-width="1" fill-opacity="0.9" stroke-opacity="0.2">
        <animate attributeType="xml" attributeName="r" from="0" to="200" dur="5s" repeatCount="indefinite" />    
    </circle>
</g>
Run Code Online (Sandbox Code Playgroud)

  • @ProllyGeek:我想知道你是否注意到答案没有解决**问题中的任何问题,从使用另一个**,更简单,形状而不是要求... (2认同)
  • @CapelliC你是对的,这项技术的新手需要了解这里的差异.@ ProllyGeek问题是如何动画比例,而不是半径.虽然实际上圆圈的视觉效果相同,但这个概念应用于其他元素的含义却大不相同.这不应该被选为正确的答案. (2认同)

Cap*_*liC 3

不完全令人满意,因为我无法保持原来的形状不变,但所需的效果似乎还可以:

<g transform="translate(300,250)">
        <g>
            <path d="M 0 -150 a 200 200 0 1 0 0.00001 0" fill="#7EEC4A"
                stroke="rgb(208,231,235)" linejoin="round" stroke-width="1" fill-opacity="0.9"
                stroke-opacity="0.2">
            </path>
            <animateTransform attributeType="xml"
                attributeName="transform"
                type="scale"
                from="0"
                to="1"
                dur="0.5s" fill="freeze" />
        </g>
    </g>
Run Code Online (Sandbox Code Playgroud)

你可以尝试这个小提琴