openfl / actuate

Actuate is a flexible, fast "tween" library for animations in Haxe
MIT License
158 stars 66 forks source link

MotionPath improvements #86

Closed chatziko closed 6 years ago

chatziko commented 6 years ago

Some bezier-related improvements:

  1. implement bezier curves of arbitrary degree (passing an array of control points). Linear and quadratic curves are treated as special cases (without any overhead). The generic method is bezierN (as of "degree n", I couldn't think of a better name).

  2. implement bezier "splines", that is smooth compositions of (cubic) beziers that pass through a given set of points (much easier to use than control points), using this technique. This is similar to GreenSock's thru beziers (at least the general concept, the exact generated path is likely different, I didn't even look at their "proprietary algorithm").

  3. To make the implementation simple, I made ComponentPath accept arbitrary IComponentPath instances as path segments. In particular, this allows to use ComponentPath itself as a segment of a larger ComponentPath. So BezierSplinePath is naturally implemented as a ComponentPath subclass, which computes the bezier segments (once the start is known) and adds them to itself.