three
Version:
JavaScript 3D library
1,491 lines (1,342 loc) • 458 kB
JavaScript
(typeof navigator !== "undefined") && (function(root, factory) {
if (typeof define === "function" && define.amd) {
define(function() {
return factory(root);
});
} else if (typeof module === "object" && module.exports) {
module.exports = factory(root);
} else {
root.lottie = factory(root);
root.bodymovin = root.lottie;
}
}((window || {}), function(window) {
"use strict";
var svgNS = "http://www.w3.org/2000/svg";
var locationHref = '';
var initialDefaultFrame = -999999;
var subframeEnabled = true;
var expressionsPlugin;
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
var cachedColors = {};
var bm_rounder = Math.round;
var bm_rnd;
var bm_pow = Math.pow;
var bm_sqrt = Math.sqrt;
var bm_abs = Math.abs;
var bm_floor = Math.floor;
var bm_max = Math.max;
var bm_min = Math.min;
var blitter = 10;
var BMMath = {};
(function(){
var propertyNames = ["abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "atan2", "ceil", "cbrt", "expm1", "clz32", "cos", "cosh", "exp", "floor", "fround", "hypot", "imul", "log", "log1p", "log2", "log10", "max", "min", "pow", "random", "round", "sign", "sin", "sinh", "sqrt", "tan", "tanh", "trunc", "E", "LN10", "LN2", "LOG10E", "LOG2E", "PI", "SQRT1_2", "SQRT2"];
var i, len = propertyNames.length;
for(i=0;i<len;i+=1){
BMMath[propertyNames[i]] = Math[propertyNames[i]];
}
}());
function ProjectInterface(){return {};}
BMMath.random = Math.random;
BMMath.abs = function(val){
var tOfVal = typeof val;
if(tOfVal === 'object' && val.length){
var absArr = createSizedArray(val.length);
var i, len = val.length;
for(i=0;i<len;i+=1){
absArr[i] = Math.abs(val[i]);
}
return absArr;
}
return Math.abs(val);
};
var defaultCurveSegments = 150;
var degToRads = Math.PI/180;
var roundCorner = 0.5519;
function roundValues(flag){
if(flag){
bm_rnd = Math.round;
}else{
bm_rnd = function(val){
return val;
};
}
}
roundValues(false);
function styleDiv(element){
element.style.position = 'absolute';
element.style.top = 0;
element.style.left = 0;
element.style.display = 'block';
element.style.transformOrigin = element.style.webkitTransformOrigin = '0 0';
element.style.backfaceVisibility = element.style.webkitBackfaceVisibility = 'visible';
element.style.transformStyle = element.style.webkitTransformStyle = element.style.mozTransformStyle = "preserve-3d";
}
function BMEnterFrameEvent(type, currentTime, totalTime, frameMultiplier){
this.type = type;
this.currentTime = currentTime;
this.totalTime = totalTime;
this.direction = frameMultiplier < 0 ? -1 : 1;
}
function BMCompleteEvent(type, frameMultiplier){
this.type = type;
this.direction = frameMultiplier < 0 ? -1 : 1;
}
function BMCompleteLoopEvent(type, totalLoops, currentLoop, frameMultiplier){
this.type = type;
this.currentLoop = currentLoop;
this.totalLoops = totalLoops;
this.direction = frameMultiplier < 0 ? -1 : 1;
}
function BMSegmentStartEvent(type, firstFrame, totalFrames){
this.type = type;
this.firstFrame = firstFrame;
this.totalFrames = totalFrames;
}
function BMDestroyEvent(type, target){
this.type = type;
this.target = target;
}
function BMRenderFrameErrorEvent(nativeError, currentTime) {
this.type = 'renderFrameError';
this.nativeError = nativeError;
this.currentTime = currentTime;
}
function BMConfigErrorEvent(nativeError) {
this.type = 'configError';
this.nativeError = nativeError;
}
function BMAnimationConfigErrorEvent(type, nativeError) {
this.type = type;
this.nativeError = nativeError;
this.currentTime = currentTime;
}
var createElementID = (function(){
var _count = 0;
return function createID() {
return '__lottie_element_' + ++_count
}
}())
function HSVtoRGB(h, s, v) {
var r, g, b, i, f, p, q, t;
i = Math.floor(h * 6);
f = h * 6 - i;
p = v * (1 - s);
q = v * (1 - f * s);
t = v * (1 - (1 - f) * s);
switch (i % 6) {
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
case 5: r = v; g = p; b = q; break;
}
return [ r,
g,
b ];
}
function RGBtoHSV(r, g, b) {
var max = Math.max(r, g, b), min = Math.min(r, g, b),
d = max - min,
h,
s = (max === 0 ? 0 : d / max),
v = max / 255;
switch (max) {
case min: h = 0; break;
case r: h = (g - b) + d * (g < b ? 6: 0); h /= 6 * d; break;
case g: h = (b - r) + d * 2; h /= 6 * d; break;
case b: h = (r - g) + d * 4; h /= 6 * d; break;
}
return [
h,
s,
v
];
}
function addSaturationToRGB(color,offset){
var hsv = RGBtoHSV(color[0]*255,color[1]*255,color[2]*255);
hsv[1] += offset;
if (hsv[1] > 1) {
hsv[1] = 1;
}
else if (hsv[1] <= 0) {
hsv[1] = 0;
}
return HSVtoRGB(hsv[0],hsv[1],hsv[2]);
}
function addBrightnessToRGB(color,offset){
var hsv = RGBtoHSV(color[0]*255,color[1]*255,color[2]*255);
hsv[2] += offset;
if (hsv[2] > 1) {
hsv[2] = 1;
}
else if (hsv[2] < 0) {
hsv[2] = 0;
}
return HSVtoRGB(hsv[0],hsv[1],hsv[2]);
}
function addHueToRGB(color,offset) {
var hsv = RGBtoHSV(color[0]*255,color[1]*255,color[2]*255);
hsv[0] += offset/360;
if (hsv[0] > 1) {
hsv[0] -= 1;
}
else if (hsv[0] < 0) {
hsv[0] += 1;
}
return HSVtoRGB(hsv[0],hsv[1],hsv[2]);
}
var rgbToHex = (function(){
var colorMap = [];
var i;
var hex;
for(i=0;i<256;i+=1){
hex = i.toString(16);
colorMap[i] = hex.length == 1 ? '0' + hex : hex;
}
return function(r, g, b) {
if(r<0){
r = 0;
}
if(g<0){
g = 0;
}
if(b<0){
b = 0;
}
return '#' + colorMap[r] + colorMap[g] + colorMap[b];
};
}());
function BaseEvent(){}
BaseEvent.prototype = {
triggerEvent: function (eventName, args) {
if (this._cbs[eventName]) {
var len = this._cbs[eventName].length;
for (var i = 0; i < len; i++){
this._cbs[eventName][i](args);
}
}
},
addEventListener: function (eventName, callback) {
if (!this._cbs[eventName]){
this._cbs[eventName] = [];
}
this._cbs[eventName].push(callback);
return function() {
this.removeEventListener(eventName, callback);
}.bind(this);
},
removeEventListener: function (eventName,callback){
if (!callback){
this._cbs[eventName] = null;
}else if(this._cbs[eventName]){
var i = 0, len = this._cbs[eventName].length;
while(i<len){
if(this._cbs[eventName][i] === callback){
this._cbs[eventName].splice(i,1);
i -=1;
len -= 1;
}
i += 1;
}
if(!this._cbs[eventName].length){
this._cbs[eventName] = null;
}
}
}
};
var createTypedArray = (function(){
function createRegularArray(type, len){
var i = 0, arr = [], value;
switch(type) {
case 'int16':
case 'uint8c':
value = 1;
break;
default:
value = 1.1;
break;
}
for(i = 0; i < len; i += 1) {
arr.push(value);
}
return arr;
}
function createTypedArray(type, len){
if(type === 'float32') {
return new Float32Array(len);
} else if(type === 'int16') {
return new Int16Array(len);
} else if(type === 'uint8c') {
return new Uint8ClampedArray(len);
}
}
if(typeof Uint8ClampedArray === 'function' && typeof Float32Array === 'function') {
return createTypedArray;
} else {
return createRegularArray;
}
}());
function createSizedArray(len) {
return Array.apply(null,{length:len});
}
function createTag(type) {
//return {appendChild:function(){},setAttribute:function(){},style:{}}
return document.createElement(type);
}
function DynamicPropertyContainer(){};
DynamicPropertyContainer.prototype = {
addDynamicProperty: function(prop) {
if(this.dynamicProperties.indexOf(prop) === -1) {
this.dynamicProperties.push(prop);
this.container.addDynamicProperty(this);
this._isAnimated = true;
}
},
iterateDynamicProperties: function(){
this._mdf = false;
var i, len = this.dynamicProperties.length;
for(i=0;i<len;i+=1){
this.dynamicProperties[i].getValue();
if(this.dynamicProperties[i]._mdf) {
this._mdf = true;
}
}
},
initDynamicPropertyContainer: function(container){
this.container = container;
this.dynamicProperties = [];
this._mdf = false;
this._isAnimated = false;
}
}
var getBlendMode = (function() {
var blendModeEnums = {
0:'source-over',
1:'multiply',
2:'screen',
3:'overlay',
4:'darken',
5:'lighten',
6:'color-dodge',
7:'color-burn',
8:'hard-light',
9:'soft-light',
10:'difference',
11:'exclusion',
12:'hue',
13:'saturation',
14:'color',
15:'luminosity'
}
return function(mode) {
return blendModeEnums[mode] || '';
}
}())
/*!
Transformation Matrix v2.0
(c) Epistemex 2014-2015
www.epistemex.com
By Ken Fyrstenberg
Contributions by leeoniya.
License: MIT, header required.
*/
/**
* 2D transformation matrix object initialized with identity matrix.
*
* The matrix can synchronize a canvas context by supplying the context
* as an argument, or later apply current absolute transform to an
* existing context.
*
* All values are handled as floating point values.
*
* @param {CanvasRenderingContext2D} [context] - Optional context to sync with Matrix
* @prop {number} a - scale x
* @prop {number} b - shear y
* @prop {number} c - shear x
* @prop {number} d - scale y
* @prop {number} e - translate x
* @prop {number} f - translate y
* @prop {CanvasRenderingContext2D|null} [context=null] - set or get current canvas context
* @constructor
*/
var Matrix = (function(){
var _cos = Math.cos;
var _sin = Math.sin;
var _tan = Math.tan;
var _rnd = Math.round;
function reset(){
this.props[0] = 1;
this.props[1] = 0;
this.props[2] = 0;
this.props[3] = 0;
this.props[4] = 0;
this.props[5] = 1;
this.props[6] = 0;
this.props[7] = 0;
this.props[8] = 0;
this.props[9] = 0;
this.props[10] = 1;
this.props[11] = 0;
this.props[12] = 0;
this.props[13] = 0;
this.props[14] = 0;
this.props[15] = 1;
return this;
}
function rotate(angle) {
if(angle === 0){
return this;
}
var mCos = _cos(angle);
var mSin = _sin(angle);
return this._t(mCos, -mSin, 0, 0, mSin, mCos, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
}
function rotateX(angle){
if(angle === 0){
return this;
}
var mCos = _cos(angle);
var mSin = _sin(angle);
return this._t(1, 0, 0, 0, 0, mCos, -mSin, 0, 0, mSin, mCos, 0, 0, 0, 0, 1);
}
function rotateY(angle){
if(angle === 0){
return this;
}
var mCos = _cos(angle);
var mSin = _sin(angle);
return this._t(mCos, 0, mSin, 0, 0, 1, 0, 0, -mSin, 0, mCos, 0, 0, 0, 0, 1);
}
function rotateZ(angle){
if(angle === 0){
return this;
}
var mCos = _cos(angle);
var mSin = _sin(angle);
return this._t(mCos, -mSin, 0, 0, mSin, mCos, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
}
function shear(sx,sy){
return this._t(1, sy, sx, 1, 0, 0);
}
function skew(ax, ay){
return this.shear(_tan(ax), _tan(ay));
}
function skewFromAxis(ax, angle){
var mCos = _cos(angle);
var mSin = _sin(angle);
return this._t(mCos, mSin, 0, 0, -mSin, mCos, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
._t(1, 0, 0, 0, _tan(ax), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
._t(mCos, -mSin, 0, 0, mSin, mCos, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
//return this._t(mCos, mSin, -mSin, mCos, 0, 0)._t(1, 0, _tan(ax), 1, 0, 0)._t(mCos, -mSin, mSin, mCos, 0, 0);
}
function scale(sx, sy, sz) {
if(!sz && sz !== 0) {
sz = 1;
}
if(sx === 1 && sy === 1 && sz === 1){
return this;
}
return this._t(sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1);
}
function setTransform(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {
this.props[0] = a;
this.props[1] = b;
this.props[2] = c;
this.props[3] = d;
this.props[4] = e;
this.props[5] = f;
this.props[6] = g;
this.props[7] = h;
this.props[8] = i;
this.props[9] = j;
this.props[10] = k;
this.props[11] = l;
this.props[12] = m;
this.props[13] = n;
this.props[14] = o;
this.props[15] = p;
return this;
}
function translate(tx, ty, tz) {
tz = tz || 0;
if(tx !== 0 || ty !== 0 || tz !== 0){
return this._t(1,0,0,0,0,1,0,0,0,0,1,0,tx,ty,tz,1);
}
return this;
}
function transform(a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2) {
var _p = this.props;
if(a2 === 1 && b2 === 0 && c2 === 0 && d2 === 0 && e2 === 0 && f2 === 1 && g2 === 0 && h2 === 0 && i2 === 0 && j2 === 0 && k2 === 1 && l2 === 0){
//NOTE: commenting this condition because TurboFan deoptimizes code when present
//if(m2 !== 0 || n2 !== 0 || o2 !== 0){
_p[12] = _p[12] * a2 + _p[15] * m2;
_p[13] = _p[13] * f2 + _p[15] * n2;
_p[14] = _p[14] * k2 + _p[15] * o2;
_p[15] = _p[15] * p2;
//}
this._identityCalculated = false;
return this;
}
var a1 = _p[0];
var b1 = _p[1];
var c1 = _p[2];
var d1 = _p[3];
var e1 = _p[4];
var f1 = _p[5];
var g1 = _p[6];
var h1 = _p[7];
var i1 = _p[8];
var j1 = _p[9];
var k1 = _p[10];
var l1 = _p[11];
var m1 = _p[12];
var n1 = _p[13];
var o1 = _p[14];
var p1 = _p[15];
/* matrix order (canvas compatible):
* ace
* bdf
* 001
*/
_p[0] = a1 * a2 + b1 * e2 + c1 * i2 + d1 * m2;
_p[1] = a1 * b2 + b1 * f2 + c1 * j2 + d1 * n2 ;
_p[2] = a1 * c2 + b1 * g2 + c1 * k2 + d1 * o2 ;
_p[3] = a1 * d2 + b1 * h2 + c1 * l2 + d1 * p2 ;
_p[4] = e1 * a2 + f1 * e2 + g1 * i2 + h1 * m2 ;
_p[5] = e1 * b2 + f1 * f2 + g1 * j2 + h1 * n2 ;
_p[6] = e1 * c2 + f1 * g2 + g1 * k2 + h1 * o2 ;
_p[7] = e1 * d2 + f1 * h2 + g1 * l2 + h1 * p2 ;
_p[8] = i1 * a2 + j1 * e2 + k1 * i2 + l1 * m2 ;
_p[9] = i1 * b2 + j1 * f2 + k1 * j2 + l1 * n2 ;
_p[10] = i1 * c2 + j1 * g2 + k1 * k2 + l1 * o2 ;
_p[11] = i1 * d2 + j1 * h2 + k1 * l2 + l1 * p2 ;
_p[12] = m1 * a2 + n1 * e2 + o1 * i2 + p1 * m2 ;
_p[13] = m1 * b2 + n1 * f2 + o1 * j2 + p1 * n2 ;
_p[14] = m1 * c2 + n1 * g2 + o1 * k2 + p1 * o2 ;
_p[15] = m1 * d2 + n1 * h2 + o1 * l2 + p1 * p2 ;
this._identityCalculated = false;
return this;
}
function isIdentity() {
if(!this._identityCalculated){
this._identity = !(this.props[0] !== 1 || this.props[1] !== 0 || this.props[2] !== 0 || this.props[3] !== 0 || this.props[4] !== 0 || this.props[5] !== 1 || this.props[6] !== 0 || this.props[7] !== 0 || this.props[8] !== 0 || this.props[9] !== 0 || this.props[10] !== 1 || this.props[11] !== 0 || this.props[12] !== 0 || this.props[13] !== 0 || this.props[14] !== 0 || this.props[15] !== 1);
this._identityCalculated = true;
}
return this._identity;
}
function equals(matr){
var i = 0;
while (i < 16) {
if(matr.props[i] !== this.props[i]) {
return false;
}
i+=1;
}
return true;
}
function clone(matr){
var i;
for(i=0;i<16;i+=1){
matr.props[i] = this.props[i];
}
}
function cloneFromProps(props){
var i;
for(i=0;i<16;i+=1){
this.props[i] = props[i];
}
}
function applyToPoint(x, y, z) {
return {
x: x * this.props[0] + y * this.props[4] + z * this.props[8] + this.props[12],
y: x * this.props[1] + y * this.props[5] + z * this.props[9] + this.props[13],
z: x * this.props[2] + y * this.props[6] + z * this.props[10] + this.props[14]
};
/*return {
x: x * me.a + y * me.c + me.e,
y: x * me.b + y * me.d + me.f
};*/
}
function applyToX(x, y, z) {
return x * this.props[0] + y * this.props[4] + z * this.props[8] + this.props[12];
}
function applyToY(x, y, z) {
return x * this.props[1] + y * this.props[5] + z * this.props[9] + this.props[13];
}
function applyToZ(x, y, z) {
return x * this.props[2] + y * this.props[6] + z * this.props[10] + this.props[14];
}
function getInverseMatrix() {
var determinant = this.props[0] * this.props[5] - this.props[1] * this.props[4];
var a = this.props[5]/determinant;
var b = - this.props[1]/determinant;
var c = - this.props[4]/determinant;
var d = this.props[0]/determinant;
var e = (this.props[4] * this.props[13] - this.props[5] * this.props[12])/determinant;
var f = - (this.props[0] * this.props[13] - this.props[1] * this.props[12])/determinant;
var inverseMatrix = new Matrix();
inverseMatrix.props[0] = a;
inverseMatrix.props[1] = b;
inverseMatrix.props[4] = c;
inverseMatrix.props[5] = d;
inverseMatrix.props[12] = e;
inverseMatrix.props[13] = f;
return inverseMatrix;
}
function inversePoint(pt) {
var inverseMatrix = this.getInverseMatrix();
return inverseMatrix.applyToPointArray(pt[0], pt[1], pt[2] || 0)
}
function inversePoints(pts){
var i, len = pts.length, retPts = [];
for(i=0;i<len;i+=1){
retPts[i] = inversePoint(pts[i]);
}
return retPts;
}
function applyToTriplePoints(pt1, pt2, pt3) {
var arr = createTypedArray('float32', 6);
if(this.isIdentity()) {
arr[0] = pt1[0];
arr[1] = pt1[1];
arr[2] = pt2[0];
arr[3] = pt2[1];
arr[4] = pt3[0];
arr[5] = pt3[1];
} else {
var p0 = this.props[0], p1 = this.props[1], p4 = this.props[4], p5 = this.props[5], p12 = this.props[12], p13 = this.props[13];
arr[0] = pt1[0] * p0 + pt1[1] * p4 + p12;
arr[1] = pt1[0] * p1 + pt1[1] * p5 + p13;
arr[2] = pt2[0] * p0 + pt2[1] * p4 + p12;
arr[3] = pt2[0] * p1 + pt2[1] * p5 + p13;
arr[4] = pt3[0] * p0 + pt3[1] * p4 + p12;
arr[5] = pt3[0] * p1 + pt3[1] * p5 + p13;
}
return arr;
}
function applyToPointArray(x,y,z){
var arr;
if(this.isIdentity()) {
arr = [x,y,z];
} else {
arr = [
x * this.props[0] + y * this.props[4] + z * this.props[8] + this.props[12],
x * this.props[1] + y * this.props[5] + z * this.props[9] + this.props[13],
x * this.props[2] + y * this.props[6] + z * this.props[10] + this.props[14]
];
}
return arr;
}
function applyToPointStringified(x, y) {
if(this.isIdentity()) {
return x + ',' + y;
}
var _p = this.props;
return Math.round((x * _p[0] + y * _p[4] + _p[12]) * 100) / 100+','+ Math.round((x * _p[1] + y * _p[5] + _p[13]) * 100) / 100;
}
function toCSS() {
//Doesn't make much sense to add this optimization. If it is an identity matrix, it's very likely this will get called only once since it won't be keyframed.
/*if(this.isIdentity()) {
return '';
}*/
var i = 0;
var props = this.props;
var cssValue = 'matrix3d(';
var v = 10000;
while(i<16){
cssValue += _rnd(props[i]*v)/v;
cssValue += i === 15 ? ')':',';
i += 1;
}
return cssValue;
}
function roundMatrixProperty(val) {
var v = 10000;
if((val < 0.000001 && val > 0) || (val > -0.000001 && val < 0)) {
return _rnd(val * v) / v;
}
return val;
}
function to2dCSS() {
//Doesn't make much sense to add this optimization. If it is an identity matrix, it's very likely this will get called only once since it won't be keyframed.
/*if(this.isIdentity()) {
return '';
}*/
var props = this.props;
var _a = roundMatrixProperty(props[0]);
var _b = roundMatrixProperty(props[1]);
var _c = roundMatrixProperty(props[4]);
var _d = roundMatrixProperty(props[5]);
var _e = roundMatrixProperty(props[12]);
var _f = roundMatrixProperty(props[13]);
return "matrix(" + _a + ',' + _b + ',' + _c + ',' + _d + ',' + _e + ',' + _f + ")";
}
return function(){
this.reset = reset;
this.rotate = rotate;
this.rotateX = rotateX;
this.rotateY = rotateY;
this.rotateZ = rotateZ;
this.skew = skew;
this.skewFromAxis = skewFromAxis;
this.shear = shear;
this.scale = scale;
this.setTransform = setTransform;
this.translate = translate;
this.transform = transform;
this.applyToPoint = applyToPoint;
this.applyToX = applyToX;
this.applyToY = applyToY;
this.applyToZ = applyToZ;
this.applyToPointArray = applyToPointArray;
this.applyToTriplePoints = applyToTriplePoints;
this.applyToPointStringified = applyToPointStringified;
this.toCSS = toCSS;
this.to2dCSS = to2dCSS;
this.clone = clone;
this.cloneFromProps = cloneFromProps;
this.equals = equals;
this.inversePoints = inversePoints;
this.inversePoint = inversePoint;
this.getInverseMatrix = getInverseMatrix;
this._t = this.transform;
this.isIdentity = isIdentity;
this._identity = true;
this._identityCalculated = false;
this.props = createTypedArray('float32', 16);
this.reset();
};
}());
/*
Copyright 2014 David Bau.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
(function (pool, math) {
//
// The following constants are related to IEEE 754 limits.
//
var global = this,
width = 256, // each RC4 output is 0 <= x < 256
chunks = 6, // at least six RC4 outputs for each double
digits = 52, // there are 52 significant digits in a double
rngname = 'random', // rngname: name for Math.random and Math.seedrandom
startdenom = math.pow(width, chunks),
significance = math.pow(2, digits),
overflow = significance * 2,
mask = width - 1,
nodecrypto; // node.js crypto module, initialized at the bottom.
//
// seedrandom()
// This is the seedrandom function described above.
//
function seedrandom(seed, options, callback) {
var key = [];
options = (options === true) ? { entropy: true } : (options || {});
// Flatten the seed string or build one from local entropy if needed.
var shortseed = mixkey(flatten(
options.entropy ? [seed, tostring(pool)] :
(seed === null) ? autoseed() : seed, 3), key);
// Use the seed to initialize an ARC4 generator.
var arc4 = new ARC4(key);
// This function returns a random double in [0, 1) that contains
// randomness in every bit of the mantissa of the IEEE 754 value.
var prng = function() {
var n = arc4.g(chunks), // Start with a numerator n < 2 ^ 48
d = startdenom, // and denominator d = 2 ^ 48.
x = 0; // and no 'extra last byte'.
while (n < significance) { // Fill up all significant digits by
n = (n + x) * width; // shifting numerator and
d *= width; // denominator and generating a
x = arc4.g(1); // new least-significant-byte.
}
while (n >= overflow) { // To avoid rounding up, before adding
n /= 2; // last byte, shift everything
d /= 2; // right using integer math until
x >>>= 1; // we have exactly the desired bits.
}
return (n + x) / d; // Form the number within [0, 1).
};
prng.int32 = function() { return arc4.g(4) | 0; };
prng.quick = function() { return arc4.g(4) / 0x100000000; };
prng.double = prng;
// Mix the randomness into accumulated entropy.
mixkey(tostring(arc4.S), pool);
// Calling convention: what to return as a function of prng, seed, is_math.
return (options.pass || callback ||
function(prng, seed, is_math_call, state) {
if (state) {
// Load the arc4 state from the given state if it has an S array.
if (state.S) { copy(state, arc4); }
// Only provide the .state method if requested via options.state.
prng.state = function() { return copy(arc4, {}); };
}
// If called as a method of Math (Math.seedrandom()), mutate
// Math.random because that is how seedrandom.js has worked since v1.0.
if (is_math_call) { math[rngname] = prng; return seed; }
// Otherwise, it is a newer calling convention, so return the
// prng directly.
else return prng;
})(
prng,
shortseed,
'global' in options ? options.global : (this == math),
options.state);
}
math['seed' + rngname] = seedrandom;
//
// ARC4
//
// An ARC4 implementation. The constructor takes a key in the form of
// an array of at most (width) integers that should be 0 <= x < (width).
//
// The g(count) method returns a pseudorandom integer that concatenates
// the next (count) outputs from ARC4. Its return value is a number x
// that is in the range 0 <= x < (width ^ count).
//
function ARC4(key) {
var t, keylen = key.length,
me = this, i = 0, j = me.i = me.j = 0, s = me.S = [];
// The empty key [] is treated as [0].
if (!keylen) { key = [keylen++]; }
// Set up S using the standard key scheduling algorithm.
while (i < width) {
s[i] = i++;
}
for (i = 0; i < width; i++) {
s[i] = s[j = mask & (j + key[i % keylen] + (t = s[i]))];
s[j] = t;
}
// The "g" method returns the next (count) outputs as one number.
me.g = function(count) {
// Using instance members instead of closure state nearly doubles speed.
var t, r = 0,
i = me.i, j = me.j, s = me.S;
while (count--) {
t = s[i = mask & (i + 1)];
r = r * width + s[mask & ((s[i] = s[j = mask & (j + t)]) + (s[j] = t))];
}
me.i = i; me.j = j;
return r;
// For robust unpredictability, the function call below automatically
// discards an initial batch of values. This is called RC4-drop[256].
// See http://google.com/search?q=rsa+fluhrer+response&btnI
};
}
//
// copy()
// Copies internal state of ARC4 to or from a plain object.
//
function copy(f, t) {
t.i = f.i;
t.j = f.j;
t.S = f.S.slice();
return t;
}
//
// flatten()
// Converts an object tree to nested arrays of strings.
//
function flatten(obj, depth) {
var result = [], typ = (typeof obj), prop;
if (depth && typ == 'object') {
for (prop in obj) {
try { result.push(flatten(obj[prop], depth - 1)); } catch (e) {}
}
}
return (result.length ? result : typ == 'string' ? obj : obj + '\0');
}
//
// mixkey()
// Mixes a string seed into a key that is an array of integers, and
// returns a shortened string seed that is equivalent to the result key.
//
function mixkey(seed, key) {
var stringseed = seed + '', smear, j = 0;
while (j < stringseed.length) {
key[mask & j] =
mask & ((smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++));
}
return tostring(key);
}
//
// autoseed()
// Returns an object for autoseeding, using window.crypto and Node crypto
// module if available.
//
function autoseed() {
try {
if (nodecrypto) { return tostring(nodecrypto.randomBytes(width)); }
var out = new Uint8Array(width);
(global.crypto || global.msCrypto).getRandomValues(out);
return tostring(out);
} catch (e) {
var browser = global.navigator,
plugins = browser && browser.plugins;
return [+new Date(), global, plugins, global.screen, tostring(pool)];
}
}
//
// tostring()
// Converts an array of charcodes to a string
//
function tostring(a) {
return String.fromCharCode.apply(0, a);
}
//
// When seedrandom.js is loaded, we immediately mix a few bits
// from the built-in RNG into the entropy pool. Because we do
// not want to interfere with deterministic PRNG state later,
// seedrandom will not call math.random on its own again after
// initialization.
//
mixkey(math.random(), pool);
//
// Nodejs and AMD support: export the implementation as a module using
// either convention.
//
// End anonymous scope, and pass initial values.
})(
[], // pool: entropy pool starts empty
BMMath // math: package containing random, pow, and seedrandom
);
var BezierFactory = (function(){
/**
* BezierEasing - use bezier curve for transition easing function
* by Gaëtan Renaudeau 2014 - 2015 – MIT License
*
* Credits: is based on Firefox's nsSMILKeySpline.cpp
* Usage:
* var spline = BezierEasing([ 0.25, 0.1, 0.25, 1.0 ])
* spline.get(x) => returns the easing value | x must be in [0, 1] range
*
*/
var ob = {};
ob.getBezierEasing = getBezierEasing;
var beziers = {};
function getBezierEasing(a,b,c,d,nm){
var str = nm || ('bez_' + a+'_'+b+'_'+c+'_'+d).replace(/\./g, 'p');
if(beziers[str]){
return beziers[str];
}
var bezEasing = new BezierEasing([a,b,c,d]);
beziers[str] = bezEasing;
return bezEasing;
}
// These values are established by empiricism with tests (tradeoff: performance VS precision)
var NEWTON_ITERATIONS = 4;
var NEWTON_MIN_SLOPE = 0.001;
var SUBDIVISION_PRECISION = 0.0000001;
var SUBDIVISION_MAX_ITERATIONS = 10;
var kSplineTableSize = 11;
var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
var float32ArraySupported = typeof Float32Array === "function";
function A (aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; }
function B (aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; }
function C (aA1) { return 3.0 * aA1; }
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
function calcBezier (aT, aA1, aA2) {
return ((A(aA1, aA2)*aT + B(aA1, aA2))*aT + C(aA1))*aT;
}
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
function getSlope (aT, aA1, aA2) {
return 3.0 * A(aA1, aA2)*aT*aT + 2.0 * B(aA1, aA2) * aT + C(aA1);
}
function binarySubdivide (aX, aA, aB, mX1, mX2) {
var currentX, currentT, i = 0;
do {
currentT = aA + (aB - aA) / 2.0;
currentX = calcBezier(currentT, mX1, mX2) - aX;
if (currentX > 0.0) {
aB = currentT;
} else {
aA = currentT;
}
} while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
return currentT;
}
function newtonRaphsonIterate (aX, aGuessT, mX1, mX2) {
for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
var currentSlope = getSlope(aGuessT, mX1, mX2);
if (currentSlope === 0.0) return aGuessT;
var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
aGuessT -= currentX / currentSlope;
}
return aGuessT;
}
/**
* points is an array of [ mX1, mY1, mX2, mY2 ]
*/
function BezierEasing (points) {
this._p = points;
this._mSampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
this._precomputed = false;
this.get = this.get.bind(this);
}
BezierEasing.prototype = {
get: function (x) {
var mX1 = this._p[0],
mY1 = this._p[1],
mX2 = this._p[2],
mY2 = this._p[3];
if (!this._precomputed) this._precompute();
if (mX1 === mY1 && mX2 === mY2) return x; // linear
// Because JavaScript number are imprecise, we should guarantee the extremes are right.
if (x === 0) return 0;
if (x === 1) return 1;
return calcBezier(this._getTForX(x), mY1, mY2);
},
// Private part
_precompute: function () {
var mX1 = this._p[0],
mY1 = this._p[1],
mX2 = this._p[2],
mY2 = this._p[3];
this._precomputed = true;
if (mX1 !== mY1 || mX2 !== mY2)
this._calcSampleValues();
},
_calcSampleValues: function () {
var mX1 = this._p[0],
mX2 = this._p[2];
for (var i = 0; i < kSplineTableSize; ++i) {
this._mSampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
}
},
/**
* getTForX chose the fastest heuristic to determine the percentage value precisely from a given X projection.
*/
_getTForX: function (aX) {
var mX1 = this._p[0],
mX2 = this._p[2],
mSampleValues = this._mSampleValues;
var intervalStart = 0.0;
var currentSample = 1;
var lastSample = kSplineTableSize - 1;
for (; currentSample !== lastSample && mSampleValues[currentSample] <= aX; ++currentSample) {
intervalStart += kSampleStepSize;
}
--currentSample;
// Interpolate to provide an initial guess for t
var dist = (aX - mSampleValues[currentSample]) / (mSampleValues[currentSample+1] - mSampleValues[currentSample]);
var guessForT = intervalStart + dist * kSampleStepSize;
var initialSlope = getSlope(guessForT, mX1, mX2);
if (initialSlope >= NEWTON_MIN_SLOPE) {
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
} else if (initialSlope === 0.0) {
return guessForT;
} else {
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
}
}
};
return ob;
}());
(function () {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
}
if(!window.requestAnimationFrame)
window.requestAnimationFrame = function (callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = setTimeout(function () {
callback(currTime + timeToCall);
},
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
if(!window.cancelAnimationFrame)
window.cancelAnimationFrame = function (id) {
clearTimeout(id);
};
}());
function extendPrototype(sources,destination){
var i, len = sources.length, sourcePrototype;
for (i = 0;i < len;i += 1) {
sourcePrototype = sources[i].prototype;
for (var attr in sourcePrototype) {
if (sourcePrototype.hasOwnProperty(attr)) destination.prototype[attr] = sourcePrototype[attr];
}
}
}
function getDescriptor(object, prop) {
return Object.getOwnPropertyDescriptor(object, prop);
}
function createProxyFunction(prototype) {
function ProxyFunction(){}
ProxyFunction.prototype = prototype;
return ProxyFunction;
}
function bezFunction(){
var easingFunctions = [];
var math = Math;
function pointOnLine2D(x1,y1, x2,y2, x3,y3){
var det1 = (x1*y2) + (y1*x3) + (x2*y3) - (x3*y2) - (y3*x1) - (x2*y1);
return det1 > -0.001 && det1 < 0.001;
}
function pointOnLine3D(x1,y1,z1, x2,y2,z2, x3,y3,z3){
if(z1 === 0 && z2 === 0 && z3 === 0) {
return pointOnLine2D(x1,y1, x2,y2, x3,y3);
}
var dist1 = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2) + Math.pow(z2 - z1, 2));
var dist2 = Math.sqrt(Math.pow(x3 - x1, 2) + Math.pow(y3 - y1, 2) + Math.pow(z3 - z1, 2));
var dist3 = Math.sqrt(Math.pow(x3 - x2, 2) + Math.pow(y3 - y2, 2) + Math.pow(z3 - z2, 2));
var diffDist;
if(dist1 > dist2){
if(dist1 > dist3){
diffDist = dist1 - dist2 - dist3;
} else {
diffDist = dist3 - dist2 - dist1;
}
} else if(dist3 > dist2){
diffDist = dist3 - dist2 - dist1;
} else {
diffDist = dist2 - dist1 - dist3;
}
return diffDist > -0.0001 && diffDist < 0.0001;
}
var getBezierLength = (function(){
return function(pt1,pt2,pt3,pt4){
var curveSegments = defaultCurveSegments;
var k;
var i, len;
var ptCoord,perc,addedLength = 0;
var ptDistance;
var point = [],lastPoint = [];
var lengthData = bezier_length_pool.newElement();
len = pt3.length;
for(k=0;k<curveSegments;k+=1){
perc = k/(curveSegments-1);
ptDistance = 0;
for(i=0;i<len;i+=1){
ptCoord = bm_pow(1-perc,3)*pt1[i]+3*bm_pow(1-perc,2)*perc*pt3[i]+3*(1-perc)*bm_pow(perc,2)*pt4[i]+bm_pow(perc,3)*pt2[i];
point[i] = ptCoord;
if(lastPoint[i] !== null){
ptDistance += bm_pow(point[i] - lastPoint[i],2);
}
lastPoint[i] = point[i];
}
if(ptDistance){
ptDistance = bm_sqrt(ptDistance);
addedLength += ptDistance;
}
lengthData.percents[k] = perc;
lengthData.lengths[k] = addedLength;
}
lengthData.addedLength = addedLength;
return lengthData;
};
}());
function getSegmentsLength(shapeData) {
var segmentsLength = segments_length_pool.newElement();
var closed = shapeData.c;
var pathV = shapeData.v;
var pathO = shapeData.o;
var pathI = shapeData.i;
var i, len = shapeData._length;
var lengths = segmentsLength.lengths;
var totalLength = 0;
for(i=0;i<len-1;i+=1){
lengths[i] = getBezierLength(pathV[i],pathV[i+1],pathO[i],pathI[i+1]);
totalLength += lengths[i].addedLength;
}
if(closed && len){
lengths[i] = getBezierLength(pathV[i],pathV[0],pathO[i],pathI[0]);
totalLength += lengths[i].addedLength;
}
segmentsLength.totalLength = totalLength;
return segmentsLength;
}
function BezierData(length){
this.segmentLength = 0;
this.points = new Array(length);
}
function PointData(partial,point){
this.partialLength = partial;
this.point = point;
}
var buildBezierData = (function(){
var storedData = {};
return function (pt1, pt2, pt3, pt4){
var bezierName = (pt1[0]+'_'+pt1[1]+'_'+pt2[0]+'_'+pt2[1]+'_'+pt3[0]+'_'+pt3[1]+'_'+pt4[0]+'_'+pt4[1]).replace(/\./g, 'p');
if(!storedData[bezierName]){
var curveSegments = defaultCurveSegments;
var k, i, len;
var ptCoord,perc,addedLength = 0;
var ptDistance;
var point,lastPoint = null;
if (pt1.length === 2 && (pt1[0] != pt2[0] || pt1[1] != pt2[1]) && pointOnLine2D(pt1[0],pt1[1],pt2[0],pt2[1],pt1[0]+pt3[0],pt1[1]+pt3[1]) && pointOnLine2D(pt1[0],pt1[1],pt2[0],pt2[1],pt2[0]+pt4[0],pt2[1]+pt4[1])){
curveSegments = 2;
}
var bezierData = new BezierData(curveSegments);
len = pt3.length;
for (k = 0; k < curveSegments; k += 1) {
point = createSizedArray(len);
perc = k / (curveSegments - 1);
ptDistance = 0;
for (i = 0; i < len; i += 1){
ptCoord = bm_pow(1-perc,3)*pt1[i]+3*bm_pow(1-perc,2)*perc*(pt1[i] + pt3[i])+3*(1-perc)*bm_pow(perc,2)*(pt2[i] + pt4[i])+bm_pow(perc,3)*pt2[i];
point[i] = ptCoord;
if(lastPoint !== null){
ptDistance += bm_pow(point[i] - lastPoint[i],2);
}
}
ptDistance = bm_sqrt(ptDistance);
addedLength += ptDistance;
bezierData.points[k] = new PointData(ptDistance, point);
lastPoint = point;
}
bezierData.segmentLength = addedLength;
storedData[bezierName] = bezierData;
}
return storedData[bezierName];
};
}());
function getDistancePerc(perc,bezierData){
var percents = bezierData.percents;
var lengths = bezierData.lengths;
var len = percents.length;
var initPos = bm_floor((len-1)*perc);
var lengthPos = perc*bezierData.addedLength;
var lPerc = 0;
if(initPos === len - 1 || initPos === 0 || lengthPos === lengths[initPos]){
return percents[initPos];
}else{
var dir = lengths[initPos] > lengthPos ? -1 : 1;
var flag = true;
while(flag){
if(lengths[initPos] <= lengthPos && lengths[initPos+1] > lengthPos){
lPerc = (lengthPos - lengths[initPos]) / (lengths[initPos+1] - lengths[initPos]);
flag = false;
}else{
initPos += dir;
}
if(initPos < 0 || initPos >= len - 1){
//FIX for TypedArrays that don't store floating point values with enough accuracy
if(initPos === len - 1) {
return percents[initPos];
}
flag = false;
}
}
return percents[initPos] + (percents[initPos+1] - percents[initPos])*lPerc;
}
}
function getPointInSegment(pt1, pt2, pt3, pt4, percent, bezierData) {
var t1 = getDistancePerc(percent,bezierData);
var u0 = 1;
var u1 = 1 - t1;
var ptX = Math.round((u1*u1*u1* pt1[0] + (t1*u1*u1 + u1*t1*u1 + u1*u1*t1)* pt3[0] + (t1*t1*u1 + u1*t1*t1 + t1*u1*t1)*pt4[0] + t1*t1*t1* pt2[0])* 1000) / 1000;
var ptY = Math.round((u1*u1*u1* pt1[1] + (t1*u1*u1 + u1*t1*u1 + u1*u1*t1)* pt3[1] + (t1*t1*u1 + u1*t1*t1 + t1*u1*t1)*pt4[1] + t1*t1*t1* pt2[1])* 1000) / 1000;
return [ptX, ptY];
}
function getSegmentArray() {
}
var bezier_segment_points = createTypedArray('float32', 8);
function getNewSegment(pt1,pt2,pt3,pt4,startPerc,endPerc, bezierData){
startPerc = startPerc < 0 ? 0 : startPerc > 1 ? 1 : startPerc;
var t0 = getDistancePerc(startPerc,bezierData);
endPerc = endPerc > 1 ? 1 : endPerc;
var t1 = getDistancePerc(endPerc,bezierData);
var i, len = pt1.length;
var u0 = 1 - t0;
var u1 = 1 - t1;
var u0u0u0 = u0*u0*u0;
var t0u0u0_3 = t0*u0*u0*3;
var t0t0u0_3 = t0*t0*u0*3;
var t0t0t0 = t0*t0*t0;
//
var u0u0u1 = u0*u0*u1;
var t0u0u1_3 = t0*u0*u1 + u0*t0*u1 + u0*u0*t1;
var t0t0u1_3 = t0*t0*u1 + u0*t0*t1 + t0*u0*t1;
var t0t0t1 = t0*t0*t1;
//
var u0u1u1 = u0*u1*u1;
var t0u1u1_3 = t0*u1*u1 + u0*t1*u1 + u0*u1*t1;
var t0t1u1_3 = t0*t1*u1 + u0*t1*t1 + t0*u1*t1;
var t0t1t1 = t0*t1*t1;
//
var u1u1u1 = u1*u1*u1;
var t1u1u1_3 = t1*u1*u1 + u1*t1*u1 + u1*u1*t1;
var t1t1u1_3 = t1*t1*u1 + u1*t1*t1 + t1*u1*t1;
var t1t1t1 = t1*t1*t1;
for(i=0;i<len;i+=1){
bezier_segment_points[i * 4] = Math.round((u0u0u0 * pt1[i] + t0u0u0_3 * pt3[i] + t0t0u0_3 * pt4[i] + t0t0t0 * pt2[i]) * 1000) / 1000;
bezier_segment_points[i * 4 + 1] = Math.round((u0u0u1 * pt1[i] + t0u0u1_3 * pt3[i] + t0t0u1_3 * pt4[i] + t0t0t1 * pt2[i]) * 1000) / 1000;
bezier_segment_points[i * 4 + 2] = Math.round((u0u1u1 * pt1[i] + t0u1u1_3 * pt3[i] + t0t1u1_3 * pt4[i] + t0t1t1 * pt2[i]) * 1000) / 1000;
bezier_segment_points[i * 4 + 3] = Math.round((u1u1u1 * pt1[i] + t1u1u1_3 * pt3[i] + t1t1u1_3 * pt4[i] + t1t1t1 * pt2[i]) * 1000) / 1000;
}
return bezier_segment_points;
}
return {
getSegmentsLength : getSegmentsLength,
getNewSegment : getNewSegment,
getPointInSegment : getPointInSegment,
buildBezierData : buildBezierData,
pointOnLine2D : pointOnLine2D,
pointOnLine3D : pointOnLine3D
};
}
var bez = bezFunction();
function dataFunctionManager(){
//var tCanvasHelper = createTag('canvas').getContext('2d');
function completeLayers(layers, comps, fontManager){
var layerData;
var animArray, lastFrame;
var i, len = layers.length;
var j, jLen, k, kLen;
for(i=0;i<len;i+=1){
layerData = layers[i];
if(!('ks' in layerData) || layerData.completed){
continue;
}
layerData.completed = true;
if(layerData.tt){
layers[i-1].td = layerData.tt;
}
animArray = [];
lastFrame = -1;
if(layerData.hasMask){
var maskProps = layerData.masksProperties;
jLen = maskProps.length;
for(j=0;j<jLen;j+=1){
if(maskProps[j].pt.k.i){
convertPathsToAbsoluteValues(maskProps[j].pt.k);
}else{
kLen = maskProps[j].pt.k.length;
for(k=0;k<kLen;k+=1){
if(maskProps[j].pt.k[k].s){
convertPathsToAbsoluteValues(maskProps[j].pt.k[k].s[0]);
}
if(maskProps[j].pt.k[k].e){
convertPathsToAbsoluteValues(maskProps[j].pt.k[k].e[0]);
}
}
}
}
}
if(layerData.ty===0){
layerData.layers = findCompLayers(layerData.refId, comps);
completeLayers(layerData.layers,comps, fontManager);
}else if(layerData.ty === 4){
completeShapes(layerData.shapes);