blob: aad5777ce1687976775f99dc55edce200883645a [file] [log] [blame]
function BaseElement(){
};
BaseElement.prototype.checkMasks = function(){
if(!this.data.hasMask){
return false;
}
var i = 0, len = this.data.masksProperties.length;
while(i<len) {
if((this.data.masksProperties[i].mode !== 'n' && this.data.masksProperties[i].cl !== false)) {
return true;
}
i += 1;
}
return false;
}
BaseElement.prototype.prepareFrame = function(num){
if(this.data.ip - this.data.st <= num && this.data.op - this.data.st > num)
{
if(this.isVisible !== true){
this.globalData.mdf = true;
this.isVisible = true;
this.firstFrame = true;
if(this.data.hasMask){
this.maskManager.firstFrame = true;
}
}
}else{
if(this.isVisible !== false){
this.globalData.mdf = true;
this.isVisible = false;
}
}
var i, len = this.dynamicProperties.length;
for(i=0;i<len;i+=1){
this.dynamicProperties[i].getValue();
if(this.dynamicProperties[i].mdf){
this.globalData.mdf = true;
}
}
if(this.data.hasMask){
this.maskManager.prepareFrame(num*this.data.sr);
}
/* TODO check this
if(this.data.sy){
if(this.data.sy[0].renderedData[num]){
if(this.data.sy[0].renderedData[num].c){
this.feFlood.setAttribute('flood-color','rgb('+Math.round(this.data.sy[0].renderedData[num].c[0])+','+Math.round(this.data.sy[0].renderedData[num].c[1])+','+Math.round(this.data.sy[0].renderedData[num].c[2])+')');
}
if(this.data.sy[0].renderedData[num].s){
this.feMorph.setAttribute('radius',this.data.sy[0].renderedData[num].s);
}
}
}
*/
this.currentFrameNum = num*this.data.sr;
return this.isVisible;
};
BaseElement.prototype.setBlendMode = function(){
var blendModeValue = '';
switch(this.data.bm){
case 1:
blendModeValue = 'multiply';
break;
case 2:
blendModeValue = 'screen';
break;
case 3:
blendModeValue = 'overlay';
break;
case 4:
blendModeValue = 'darken';
break;
case 5:
blendModeValue = 'lighten';
break;
case 6:
blendModeValue = 'color-dodge';
break;
case 7:
blendModeValue = 'color-burn';
break;
case 8:
blendModeValue = 'hard-light';
break;
case 9:
blendModeValue = 'soft-light';
break;
case 10:
blendModeValue = 'difference';
break;
case 11:
blendModeValue = 'exclusion';
break;
case 12:
blendModeValue = 'hue';
break;
case 13:
blendModeValue = 'saturation';
break;
case 14:
blendModeValue = 'color';
break;
case 15:
blendModeValue = 'luminosity';
break;
}
this.layerElement.style['mix-blend-mode'] = blendModeValue;
}
BaseElement.prototype.init = function(){
if(!this.data.sr){
this.data.sr = 1;
}
this.dynamicProperties = [];
if(this.data.ef && expressionsPlugin){
this.effectsManager = expressionsPlugin.getEffectsManager(this.data,this,this.dynamicProperties);
this.effect = this.effectsManager.bind(this.effectsManager);
}
//this.elemInterface = buildLayerExpressionInterface(this);
this.hidden = false;
this.firstFrame = true;
this.isVisible = false;
this.currentFrameNum = -99999;
this.lastNum = -99999;
this.finalTransform = {
mProp: PropertyFactory.getProp(this,this.data.ks,2,null,this.dynamicProperties),
matMdf: false,
opMdf: false,
mat: new Matrix(),
opacity: 1
};
this.finalTransform.op = this.finalTransform.mProp.o;
this.transform = this.finalTransform.mProp;
if(this.data.ty !== 11){
this.createElements();
}
if(this.data.hasMask){
this.addMasks(this.data);
}
};
BaseElement.prototype.getType = function(){
return this.type;
};
BaseElement.prototype.resetHierarchy = function(){
if(!this.hierarchy){
this.hierarchy = [];
}else{
this.hierarchy.length = 0;
}
};
BaseElement.prototype.getHierarchy = function(){
if(!this.hierarchy){
this.hierarchy = [];
}
return this.hierarchy;
};
BaseElement.prototype.getLayerSize = function(){
if(this.data.ty === 5){
return {w:this.data.textData.width,h:this.data.textData.height};
}else{
return {w:this.data.width,h:this.data.height};
}
};
BaseElement.prototype.hide = function(){
};
BaseElement.prototype.mHelper = new Matrix();