easing-coordinates
Advanced tools
Comparing version 2.0.1 to 2.0.2
'use strict' | ||
var __importDefault = | ||
(this && this.__importDefault) || | ||
function(mod) { | ||
return mod && mod.__esModule ? mod : { default: mod } | ||
} | ||
var __importStar = | ||
(this && this.__importStar) || | ||
function(mod) { | ||
if (mod && mod.__esModule) return mod | ||
var result = {} | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k] | ||
result['default'] = mod | ||
return result | ||
} | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
const cubic_coordinates_1 = require('./lib/cubic-coordinates') | ||
exports.cubicCoordinates = cubic_coordinates_1.cubicCoordinates | ||
const easing_map_1 = require('./lib/easing-map') | ||
const shared = require('./lib/shared') | ||
const easing_map_1 = __importDefault(require('./lib/easing-map')) | ||
const shared = __importStar(require('./lib/shared')) | ||
const steps_coordinates_1 = require('./lib/steps-coordinates') | ||
@@ -8,0 +22,0 @@ exports.stepsCoordinates = steps_coordinates_1.stepsCoordinates |
'use strict' | ||
var __importStar = | ||
(this && this.__importStar) || | ||
function(mod) { | ||
if (mod && mod.__esModule) return mod | ||
var result = {} | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k] | ||
result['default'] = mod | ||
return result | ||
} | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
const shared = require('./shared') | ||
function points(polySteps) { | ||
const shared = __importStar(require('./shared')) | ||
function getBezier(t, n1, n2) { | ||
return ( | ||
(1 - t) * (1 - t) * (1 - t) * 0 + | ||
3 * ((1 - t) * (1 - t)) * t * n1 + | ||
3 * (1 - t) * (t * t) * n2 + | ||
t * t * t * 1 | ||
) | ||
} | ||
function cubicCoordinates(x1, y1, x2, y2, polySteps = 10) { | ||
const increment = 1 / polySteps | ||
@@ -9,27 +26,6 @@ let coordinates = [] | ||
coordinates.push({ | ||
x: getX(i), | ||
y: getY(i), | ||
x: getBezier(i, x1, x2), | ||
y: getBezier(i, y1, y2), | ||
}) | ||
} | ||
return coordinates | ||
} | ||
function getX(t, x1, x2) { | ||
return ( | ||
(1 - t) * (1 - t) * (1 - t) * 0 + | ||
3 * ((1 - t) * (1 - t)) * t * x1 + | ||
3 * (1 - t) * (t * t) * x2 + | ||
t * t * t * 1 | ||
) | ||
} | ||
function getY(t, y1, y2) { | ||
return ( | ||
(1 - t) * (1 - t) * (1 - t) * 0 + | ||
3 * ((1 - t) * (1 - t)) * t * y1 + | ||
3 * (1 - t) * (t * t) * y2 + | ||
t * t * t * 1 | ||
) | ||
} | ||
function cubicCoordinates(x1, y1, x2, y2, polySteps = 10) { | ||
const curve = new Bezier(0, 0, x1, y1, x2, y2, 1, 1) | ||
const coordinates = curve.getLUT(polySteps) | ||
const roundedCoordinates = coordinates.map(obj => shared.getCoordinate(obj.x, obj.y)) | ||
@@ -36,0 +32,0 @@ return roundedCoordinates |
'use strict' | ||
var __importStar = | ||
(this && this.__importStar) || | ||
function(mod) { | ||
if (mod && mod.__esModule) return mod | ||
var result = {} | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k] | ||
result['default'] = mod | ||
return result | ||
} | ||
Object.defineProperty(exports, '__esModule', { value: true }) | ||
const shared = require('./shared') | ||
const shared = __importStar(require('./shared')) | ||
function stepsCoordinates(steps, skip = 'skip-end') { | ||
@@ -5,0 +14,0 @@ const coordinates = [] |
import * as shared from './shared' | ||
function points(polySteps) { | ||
function getBezier(t, n1, n2) { | ||
return ( | ||
(1 - t) * (1 - t) * (1 - t) * 0 + | ||
3 * ((1 - t) * (1 - t)) * t * n1 + | ||
3 * (1 - t) * (t * t) * n2 + | ||
t * t * t * 1 | ||
) | ||
} | ||
export function cubicCoordinates(x1, y1, x2, y2, polySteps = 10) { | ||
const increment = 1 / polySteps | ||
@@ -7,29 +15,8 @@ let coordinates = [] | ||
coordinates.push({ | ||
x: getX(i), | ||
y: getY(i), | ||
x: getBezier(i, x1, x2), | ||
y: getBezier(i, y1, y2), | ||
}) | ||
} | ||
return coordinates | ||
} | ||
function getX(t, x1, x2) { | ||
return ( | ||
(1 - t) * (1 - t) * (1 - t) * 0 + | ||
3 * ((1 - t) * (1 - t)) * t * x1 + | ||
3 * (1 - t) * (t * t) * x2 + | ||
t * t * t * 1 | ||
) | ||
} | ||
function getY(t, y1, y2) { | ||
return ( | ||
(1 - t) * (1 - t) * (1 - t) * 0 + | ||
3 * ((1 - t) * (1 - t)) * t * y1 + | ||
3 * (1 - t) * (t * t) * y2 + | ||
t * t * t * 1 | ||
) | ||
} | ||
export function cubicCoordinates(x1, y1, x2, y2, polySteps = 10) { | ||
const curve = new Bezier(0, 0, x1, y1, x2, y2, 1, 1) | ||
const coordinates = curve.getLUT(polySteps) | ||
const roundedCoordinates = coordinates.map(obj => shared.getCoordinate(obj.x, obj.y)) | ||
return roundedCoordinates | ||
} |
{ | ||
"name": "easing-coordinates", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Utility script that takes an easing function as input and outputs a coordinate set with adjustable precision/resolution.", | ||
@@ -5,0 +5,0 @@ "repository": { |
28252
670