Timing Function
Simple API for easing functions and Bezier curves
Installation
Install with npm:
npm install timing-function
Usage
var t = ; // choose any timing functionvar func = t; // func now takes a float between 0 and 1; // returns 0.45 // for cubic-bezier:func = t; ;
Functions
// lineart // sinettt // quadttt // cubicttt // quartttt // quintttt // expottt // circttt // sinettt // cubic-bezier (works just like css` cubic-bezier())t
Functions are also available with direct calls:
tsine
UnitBezier
Normally, using timingFunction.get(p1x, p1y, p2x, p2y)
should suffice for cubic-beziers. But if you need to directly work with the bezier class, here is an examples for it:
var UnitBezier = UnitBezier; var b = 01 02 03 04; // to solve a point:b; // to solve with custom epsilon:b; // to reset control points:b;
Acknowledgements
Trig functions come from MooTools, and cubic-bezier calculator comes from here.
License
MIT