Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/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 - Fatal编程技术网

Animation 设置半圆路径动画的svg

Animation 设置半圆路径动画的svg,animation,svg,Animation,Svg,我正在尝试制作一个圆环图,我想在值发生变化时设置半圆路径的动画,但“d”路径的变换看起来并不“自然”。以下是我到目前为止得到的信息: <svg height="400" width="400" style="background: #fff"> <g transform="translate(200,200), scale(75)" stroke-width="0.01" stroke="white"> <path d="M 1 0 L 2 0 A 2

我正在尝试制作一个圆环图,我想在值发生变化时设置半圆路径的动画,但“d”路径的变换看起来并不“自然”。以下是我到目前为止得到的信息:

<svg height="400" width="400" style="background: #fff">
  <g transform="translate(200,200), scale(75)" stroke-width="0.01" stroke="white">
    <path d="M 1 0 L 2 0 A 2 2 0 0 1 -1.03903 -0.166952 L -0.519515 -0.0834762 A 1 1 0 0 0 1 0" stroke-width="0.01" stroke="black" fill="green">
      <animate attributeName="d" from="M 1 0 L 2 0 A 2 2 0 1 1 0.10467191248588789 -1.9972590695091477 L 0.052335956242943946 -0.9986295347545738 A 1 1 0 1 0 1 0" to="M 1 0 L 2 0 A 2 2 0 0 1 -1.7492394142787915 0.9696192404926743 L -0.8746197071393957 0.48480962024633717 A 1 1 0 0 0 1 0" dur="1s" repeatCount="indefinite"></animate>
    </path>
  </g>
</svg>

我希望有一种方法可以像在一条路径之后一样对其进行动画制作,使动画看起来像是圆继续增长或变小,但在动画制作时不会向更窄的方向移动。 提前谢谢你,丹尼尔。

只需根据需要调整路径即可

.path {
  stroke-dasharray: 500;
  stroke-dashoffset: 0;
  animation: dash 10s;
  animation-fill-mode: both;
}

@keyframes dash {
  from { stroke-dashoffset: 500; }
  to { stroke-dashoffset: 0; }
}

<svg version="1.1" baseProfile="basic" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 800 500" xml:space="preserve">
    <path style="fill:#FFFFFF;stroke:green;stroke-miterlimit:10;" stroke-width="50" d="M98,127c0,0,1.614,107.653,92,116s108-116,108-116" class="path"/>
</svg>
.path{
行程:500;
笔划偏移:0;
动画:dash 10s;
动画填充模式:两者都有;
}
@关键帧破折号{
从{stroke dashoffset:500;}
到{stroke dashoffset:0;}
}
只需根据需要调整路径即可

.path {
  stroke-dasharray: 500;
  stroke-dashoffset: 0;
  animation: dash 10s;
  animation-fill-mode: both;
}

@keyframes dash {
  from { stroke-dashoffset: 500; }
  to { stroke-dashoffset: 0; }
}

<svg version="1.1" baseProfile="basic" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 800 500" xml:space="preserve">
    <path style="fill:#FFFFFF;stroke:green;stroke-miterlimit:10;" stroke-width="50" d="M98,127c0,0,1.614,107.653,92,116s108-116,108-116" class="path"/>
</svg>
.path{
行程:500;
笔划偏移:0;
动画:dash 10s;
动画填充模式:两者都有;
}
@关键帧破折号{
从{stroke dashoffset:500;}
到{stroke dashoffset:0;}
}

您需要绘制圆弧,以便大圆弧和扫掠标志在动画期间不会更改。Firefox拒绝这样的动画,正是因为它们不能正常工作。我可以创建一个圆形的动画路径,使动画沿着该路径移动吗?即使你避免从弧形标志处突然跳转,你也不会得到你想要的动画。设置
d
属性的动画时,点以直线过渡。您确实需要使用JavaScript来获取沿圆弧曲线设置动画的点。d3有很多可用的例子,你可以看看他们的源代码并加以修改。我不想依赖第三方LIB,我看到你可以使用路径设置动画,路径也可以是曲线,但我不知道如何使用路径循环进行变形。你需要绘制圆弧,以便大圆弧和扫描标志在动画期间不会改变。Firefox拒绝这样的动画,正是因为它们不能正常工作。我可以创建一个圆形的动画路径,使动画沿着该路径移动吗?即使你避免从弧形标志处突然跳转,你也不会得到你想要的动画。设置
d
属性的动画时,点以直线过渡。您确实需要使用JavaScript来获取沿圆弧曲线设置动画的点。d3有很多可用的例子,你可以看看他们的源代码并加以修改。我不想依赖第三方LIB,我看到你可以通过使用路径来制作动画,路径也可以是曲线,但我不知道如何通过使用路径圆环来变形非常感谢你的回答,这正是我需要的!干杯谢谢如果你喜欢的话,你可能也会对如何画一个看起来是用手随机画的圆感到高兴。非常感谢你的回答,这正是我需要的!干杯谢谢如果你喜欢的话,你也可以从中得到乐趣,学习如何画一个看起来是用手随机画的圆。