牧人羊
2017-06-19 01:22
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>SVG -- 轨迹移动</title>
<style>
html, body, svg {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<svg viewBox='-400 -400 800 800'>
<!-- 切换曲线时,需要改变 x, y 值 -->
<rect x='-225' y='-25' width= '50' height='50' fill='rgba(0, 255, 255, .5)'>
<animateMotion
dur='3s'
rotate='auto'
fill='freeze'
repeatCount='1'
>
<mpath xlink:href='#sPath'></mpath>
</animateMotion>
</rect>
<!-- 视频演示画的曲线 -->
<!-- <path id='sPath' d='M 0 0 L 100 100 A 200 200 0 1 0 0 -100' stroke='gray' fill='none'></path> -->
<!-- quadratic curve 沿着贝塞尔曲线移动有问题? -->
<path id='sPath' d='M -200 0 Q -100 -200 0 0 T 200 0' stroke='gray' fill='none'></path>
</svg>
</body>
</html>
rect 的 x坐标错了,代码里为x=-225,改为x=-25
走进SVG
52638 学习 · 213 问题
相似问题