Easing Coordinates

Usage
The easingCoordinates function takes steps and cubic-bezier
single-transition-timing-functions
as input and returns an array of "low-poly" xy-coordinates.
import { easingCoordinates } from 'easing-coordinates'
easingCoordinates('cubic-bezier(0.5, 0, 0.5, 1)')
easingCoordinates('steps(4)')
Use stepsCoordinates
and cubicCoordinates
methods directly depending on your
data:
import { cubicCoordinates, easingCoordinates, stepsCoordinates } from './index'
easingCoordinates('cubic-bezier(0.42, 0, 0.58, 1)') ==
cubicCoordinates(0.42, 0, 0.58, 1)
easingCoordinates('steps(4, skip-end)') == stepsCoordinates(4, 'skip-end')
Increase hypotSize (default = 0.1) to get a "lower-poly" version of your cubic-bezier
functions and make sure incrementSize is always smaller than hypotSize.
interface ICoordinate {
x: number
y: number
}
function easingCoordinates(
easingFunction: string,
hypotSize?: number,
incrementSize?: number
): ICoordinate[]
function stepsCoordinates(steps: number, skip = 'skip-end'): ICoordinate[]
function cubicCoordinates(
x1: number,
y1: number,
x2: number,
y2: number,
hypotSize = 0.1,
incrementSize = 0.001
): ICoordinate[]
Build
(See package.json for more scripts)
npm install
npm run watch
npm run test