blob: a0584772958dfb647d857d1349abdbdbb8e9851c [file] [log] [blame]
function ISolidElement(data,parentContainer,globalData, placeholder){
this.parent.constructor.call(this,data,parentContainer,globalData, placeholder);
}
createElement(BaseElement, ISolidElement);
ISolidElement.prototype.createElements = function(){
this.parent.createElements.call(this);
var rect = document.createElementNS(svgNS,'rect');
rect.setAttribute('width',this.data.sw);
rect.setAttribute('height',this.data.sh);
/*rect.setAttribute('width',1);
rect.setAttribute('height',1);*/
rect.setAttribute('fill',this.data.sc);
if(this.layerElement === this.parentContainer){
this.appendNodeToParent(rect);
}else{
this.layerElement.appendChild(rect);
}
this.rectElement = rect;
};
ISolidElement.prototype.hide = function(){
if(!this.hidden){
this.rectElement.setAttribute('visibility','hidden');
this.hidden = true;
}
};
ISolidElement.prototype.renderFrame = function(num,parentMatrix){
var renderParent = this.parent.renderFrame.call(this,num,parentMatrix);
if(renderParent===false){
this.hide();
return;
}
if(this.hidden){
this.hidden = false;
this.rectElement.setAttribute('visibility', 'visible');
}
if(!this.data.hasMask){
if(!this.renderedFrames[this.globalData.frameNum]){
var tr = 'matrix('+this.finalTransform.mat.props.join(',')+')';
if(this.lastData && this.lastData.tr === tr && this.lastData.o === this.finalTransform.opacity){
this.renderedFrames[this.globalData.frameNum] = this.lastData;
}else{
this.renderedFrames[this.globalData.frameNum] = new RenderedFrame(tr,this.finalTransform.opacity);
}
}
var renderedFrameData = this.renderedFrames[this.globalData.frameNum];
if(this.lastData.tr != renderedFrameData.tr){
this.rectElement.setAttribute('transform',renderedFrameData.tr);
}
if(this.lastData.o !== renderedFrameData.o){
this.rectElement.setAttribute('opacity',renderedFrameData.o);
}
this.lastData = renderedFrameData;
}
};
ICompElement.prototype.destroy = function(){
this.parent.destroy.call();
this.rectElement = null;
};