@mapbox/unitbezier
unit bezier curve interpolation
Last updated 6 months ago by mbx-npm-03-production .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @mapbox/unitbezier 
SYNC missed versions from official npm registry.

Node

unitbezier

Unit bezier interpolation function: a port to JavaScript from Webkit:

http://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/UnitBezier.h

API

import unitBezier from '@mapbox/unitbezier';

const ease = unitBezier(0.25, 0.1, 0.25, 1); // CSS `ease`
ease(0.5);        // → 0.8024…
ease(0.5, 1e-8);  // tighter precision

unitBezier(p1x, p1y, p2x, p2y)

Returns a function that evaluates the cubic bezier curve defined by control points (0,0), (p1x, p1y), (p2x, p2y), (1,1).

ease(x, epsilon?)

Evaluate the curve for x (clamped to [0, 1]). epsilon controls solver precision (default 1e-6).

Current Tags

  • 1.0.0                                ...           latest (6 months ago)

3 Versions

  • 1.0.0                                ...           6 months ago
  • 0.0.1                                ...           5 years ago
  • 0.0.0                                ...           10 years ago

© 2010 - cnpmjs.org x YWFE | Home | YWFE