blob: 2ff0a896d30661e11b704e6d8ae21d08ea4b3243 [file] [log] [blame]
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 = Object.getOwnPropertyNames(Math);
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(n,c,t,d){
this.type = n;
this.currentTime = c;
this.totalTime = t;
this.direction = d < 0 ? -1:1;
}
function BMCompleteEvent(n,d){
this.type = n;
this.direction = d < 0 ? -1:1;
}
function BMCompleteLoopEvent(n,c,t,d){
this.type = n;
this.currentLoop = t;
this.totalLoops = c;
this.direction = d < 0 ? -1:1;
}
function BMSegmentStartEvent(n,f,t){
this.type = n;
this.firstFrame = f;
this.totalFrames = t;
}
function BMDestroyEvent(n,t){
this.type = n;
this.target = t;
}
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];
};
}());