actuate
Version:
Actuate is a flexible, fast "tween" library for animations
81 lines (63 loc) • 1.94 kB
JavaScript
// Class: motion._MotionPath.BezierPath
var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this
$global.Object.defineProperty(exports, "__esModule", {value: true});
var __map_reserved = {};
// Imports
var $hxClasses = require("./../../hxClasses_stub").default;
var $import = require("./../../import_stub").default;
function motion_IComponentPath() {return require("./../../motion/IComponentPath");}
// Constructor
var BezierPath = function(end,control,strength) {
this._end = end;
this.control = control;
this.strength = strength;
}
// Meta
BezierPath.__name__ = ["motion","_MotionPath","BezierPath"];
BezierPath.__isInterface__ = false;
BezierPath.__interfaces__ = [(motion_IComponentPath().default)];
BezierPath.prototype = {
calculate: function(k) {
var l = 1 - k;
var _g = this.control.length;
switch(_g) {
case 0:
return l * this._start + k * this._end;
case 1:
return l * l * this._start + 2 * l * k * this.control[0] + k * k * this._end;
case 2:
return l * l * l * this._start + 3 * l * l * k * this.control[0] + 3 * l * k * k * this.control[1] + k * k * k * this._end;
default:
if(l < 1e-7) {
return this._end;
}
var r = k / l;
var n = this.control.length + 1;
var coeff = Math.pow(l,n);
var res = coeff * this._start;
var _g1 = 1;
var _g2 = n;
while(_g1 < _g2) {
var i = _g1++;
coeff *= r * (n + 1 - i) / i;
res += coeff * this.control[i - 1];
}
coeff *= r / n;
return res + coeff * this._end;
}
},
get_start: function() {
return this._start;
},
set_start: function(value) {
return this._start = value;
},
get_end: function() {
return this._end;
}
};
BezierPath.prototype.__class__ = BezierPath.prototype.constructor = $hxClasses["motion._MotionPath.BezierPath"] = BezierPath;
// Init
// Statics
// Export
exports.default = BezierPath;