Shape tween in javascript

后端 未结 5 855
走了就别回头了
走了就别回头了 2020-12-17 20:49

Is there a way to do a shape tween in javascript? Using canvas maybe...

5条回答
  •  眼角桃花
    2020-12-17 21:03

    Shape tween as in Flash is harder to find than motion tween and simple attributes interpolation (like in JSTweener, Tween.lib, JQuery's animate(), d3's transition(), RaphaelJS's animate(), etc.). Those libraries, some cited in the other answers, don't do shape tweening.

    You first need to know if you want to draw with SVG or with canvas and what library you will be using. Then, you need an interpolator, a function that will compute the transition between two given shapes, that can write a proper path in SVG or canvas. I wrote an implementation for SVG in D3.js to do some animated transitions between a lot of different shapes (using Gielis's superformula), if someone still need one. You can find an example here

提交回复
热议问题