How to use @mapbox/unitbezier - 4 common examples

To help you get started, we’ve selected a few @mapbox/unitbezier examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mapbox / mapbox-gl-js / src / util / util.js View on Github external
export function bezier(p1x: number, p1y: number, p2x: number, p2y: number): (t: number) => number {
    const bezier = new UnitBezier(p1x, p1y, p2x, p2y);
    return function(t: number) {
        return bezier.solve(t);
    };
}
github mapbox / mapbox-gl-js / src / util / util.js View on Github external
export function bezier(p1x: number, p1y: number, p2x: number, p2y: number): (t: number) => number {
    const bezier = new UnitBezier(p1x, p1y, p2x, p2y);
    return function(t: number) {
        return bezier.solve(t);
    };
}
github omnisci / mapd-charting / src / utils / mapbox-ported-functions.js View on Github external
export function bezier(p1x, p1y, p2x, p2y) {
  const bezier = new UnitBezier(p1x, p1y, p2x, p2y)
  return function(t) {
    return bezier.solve(t)
  }
}
/**
github mapbox / mapbox-gl-js / src / style-spec / expression / definitions / interpolate.js View on Github external
static interpolationFactor(interpolation: InterpolationType, input: number, lower: number, upper: number) {
        let t = 0;
        if (interpolation.name === 'exponential') {
            t = exponentialInterpolation(input, interpolation.base, lower, upper);
        } else if (interpolation.name === 'linear') {
            t = exponentialInterpolation(input, 1, lower, upper);
        } else if (interpolation.name === 'cubic-bezier') {
            const c = interpolation.controlPoints;
            const ub = new UnitBezier(c[0], c[1], c[2], c[3]);
            t = ub.solve(exponentialInterpolation(input, 1, lower, upper));
        }
        return t;
    }

@mapbox/unitbezier

unit bezier curve interpolation

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis

Popular @mapbox/unitbezier functions