简体   繁体   English

Raphael.js中的自定义动画

[英]Custom Animation in Raphael.js

Hyphotesis Hyphotesis

I have some circles on a path (see start shape in figure) and they need to animate to another path (end shape in figure). 我在路径上有一些圆圈(参见图中的起始形状),他们需要动画到另一条路径(图中的最终形状)。

There are several actions the animation must do: 动画必须执行以下操作:
- move the entire shape to the new position - 将整个形状移动到新位置
- change the path - 改变路径
- decrease all circle radii - 减少所有圆半径

The figure: 图:
开始和结束位置

Problem 问题

Raphael.js knows how to animate the circles from the original coordinates to the final ones also changing the radius. Raphael.js知道如何设置从原始坐标到最终坐标的圆形动画,同时改变半径。 Because the animation doesn't run on a similar path like the original and final ones, the animation doesn't look very good. 因为动画不像原始动画和最终动画那样在类似路径上运行,所以动画看起来不太好。 The circles go from x1,y1 to x2,y2 in a straight line. 圆圈以直线从x1,y1到x2,y2。

What I tried 我尝试了什么

  1. Doing the straight-forward animation, moving the circles from start to end, changing the radius. 执行直接动画,从开始到结束移动圆圈,更改半径。 Like I said, this isn't ok. 就像我说的,这不行。

  2. Moving every circle in intervals, calculating the new path on every iteration and calculating the position of the circles. 以间隔移动每个圆,计算每次迭代的新路径并计算圆的位置。 This runs very slow. 这很慢。

  3. Calculating a temporary circle position on each iteration with Element.getPointAtLength(). 使用Element.getPointAtLength()计算每次迭代的临时圆位置。 This is also very slow. 这也很慢。

  4. Having a few intermediary paths hardcoded in arrays and running the animation through each one. 将一些中间路径硬编码在数组中并通过每个路径运行动画。 This is better in terms of speed but looks kind of jerky 这在速度方面更好,但看起来有点生涩

So, any ideas? 那么,有什么想法吗?

http://irunmywebsite.com/raphael/additionalhelp.php?v=2&q=element.getpointatlength http://irunmywebsite.com/raphael/additionalhelp.php?v=2&q=element.getpointatlength

I'm on iPod so not saying much, but this might help 我在iPod上这么说不多,但这可能会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM