Animation 无法沿Inkscape中生成的路径设置SVG动画
我在Inkscape中生成了以下SVG,它有一个Pacman图形(Animation 无法沿Inkscape中生成的路径设置SVG动画,animation,svg,inkscape,Animation,Svg,Inkscape,我在Inkscape中生成了以下SVG,它有一个Pacman图形(id=Pacman)和一个路径(id=trackit)。目标是使图形沿路径移动 将图像保存到文件后,我通过在Pacman图中添加以下部分对其进行编辑: <animateMotion path="m 39.645298,114.12279 c 24.797657,0.79422 33.02086,-32.601373 61.073142,-32.542731 27.55775,0.05761 3
id=Pacman
)和一个路径(id=trackit
)。目标是使图形沿路径移动
将图像保存到文件后,我通过在Pacman图中添加以下部分对其进行编辑:
<animateMotion
path="m 39.645298,114.12279 c 24.797657,0.79422 33.02086,-32.601373 61.073142,-32.542731 27.55775,0.05761 37.28264,-38.721653 63.91959,-39.287919"
begin="2s"
dur="10s"
repeatCount="indefinite"
rotate="auto" />
问题是动画不起作用。按照begin=“2s”
的定义,2秒钟后,黄色数字就会消失
我的第一个猜测是,坐标在某种程度上是偏移的,而吃豆人的形状在外层空间的某个地方是动画。然而,如果是这样的话,那么我会看到形状在每个循环开始时会恢复一些时间
当我用各种教程中的手写SVG进行实验时,它们是有效的。然而,我自己在Inkscape中制作的那些并不像预期的那样
这是什么原因,如何纠正?为了了解发生了什么,请在svg元素中添加
溢出:可见。你会看到小贩正在远离小路的地方徘徊
在下一个例子中,我将把你的小贩换成一个圆圈。圆的路径以点{x:0,y:0}为中心您应该重写packman的路径,使其从svg元素的原点开始
svg{border:1px solid;}
您需要将pacman形状居中于原点(0,0)。或者需要从0,0开始运动路径。pacman的偏移量将添加到运动路径位置的偏移量中。这意味着您的pacman将离开屏幕底部。实际上,在原始文件的pacman形状中设置sodipodi:cx=“0”sodipodi:cy=“0”
就足够了。有一件事仍然不清楚-如果我使用Inkscape编辑文件,并且我有一张复杂的图片,其中包含许多移动元素,这些元素应该沿着路径移动-将它们全部放到0,0
会破坏图像本身。当动画在浏览器中实时显示时效果很好,但在Inkscape中编辑静态图像时效果很好-移动的对象不在它们所属的位置。这是最佳实践吗?这是动画圈对cx
或cy
没有价值的地方,这相当于cx=“0”cy=“0”
。如果在动画开始前的2秒钟内看到packman,您可以更改SVG元素的viewBox,以便原点0,0
位于画布之外
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="165.06496mm"
height="104.70296mm"
viewBox="0 0 165.06496 104.70296"
version="1.1"
id="svg8"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="clean-animation.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4"
inkscape:cx="343.91864"
inkscape:cy="205.09936"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1920"
inkscape:window-height="1005"
inkscape:window-x="-9"
inkscape:window-y="1071"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-19.575883,-23.159755)">
<path
style="opacity:0.597;fill:#ffff00;fill-opacity:1;stroke:#008000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:0.26458331, 0.52916662999999997;stroke-dashoffset:0;stroke-opacity:0.8"
id="pacman"
sodipodi:type="arc"
sodipodi:cx="33.408691"
sodipodi:cy="115.25672"
sodipodi:rx="13.698855"
sodipodi:ry="12.473214"
sodipodi:start="0"
sodipodi:end="5.9207142"
d="m 47.107547,115.25672 a 13.698855,12.473214 0 0 1 -12.459194,12.42204 13.698855,12.473214 0 0 1 -14.714154,-10.1738 13.698855,12.473214 0 0 1 9.796115,-14.26337 13.698855,12.473214 0 0 1 16.487129,7.59231 l -12.808752,4.42282 z"
inkscape:label="#path815">
<animateMotion
path="m 39.645298,114.12279 c 24.797657,0.79422 33.02086,-32.601373 61.073142,-32.542731 27.55775,0.05761 37.28264,-38.721653 63.91959,-39.287919"
begin="2s"
dur="10s"
repeatCount="indefinite"
rotate="auto" />
</path>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 39.645298,114.12279 c 24.797657,0.79422 33.02086,-32.601373 61.073142,-32.542731 27.55775,0.05761 37.28264,-38.721653 63.91959,-39.287919"
id="trajectory"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csc"
inkscape:label="#path817" />
</g>
</svg>