mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-12 03:06:54 +01:00
36 lines
912 B
JavaScript
36 lines
912 B
JavaScript
/**
|
|
* @private
|
|
*/
|
|
export function _pointInLine(p1, p2, t, mode) { // eslint-disable-line no-unused-vars
|
|
return {
|
|
x: p1.x + t * (p2.x - p1.x),
|
|
y: p1.y + t * (p2.y - p1.y)
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
export function _steppedInterpolation(p1, p2, t, mode) {
|
|
return {
|
|
x: p1.x + t * (p2.x - p1.x),
|
|
y: mode === 'middle' ? t < 0.5 ? p1.y : p2.y
|
|
: mode === 'after' ? t < 1 ? p1.y : p2.y
|
|
: t > 0 ? p2.y : p1.y
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
export function _bezierInterpolation(p1, p2, t, mode) { // eslint-disable-line no-unused-vars
|
|
const cp1 = {x: p1.controlPointNextX, y: p1.controlPointNextY};
|
|
const cp2 = {x: p2.controlPointPreviousX, y: p2.controlPointPreviousY};
|
|
const a = _pointInLine(p1, cp1, t);
|
|
const b = _pointInLine(cp1, cp2, t);
|
|
const c = _pointInLine(cp2, p2, t);
|
|
const d = _pointInLine(a, b, t);
|
|
const e = _pointInLine(b, c, t);
|
|
return _pointInLine(d, e, t);
|
|
}
|