P.clear = function () {
const {element, engine, backgroundColor, clearAlpha} = this;
this.prepareStamp();
const width = _floor(element.width),
height = _floor(element.height);
if (backgroundColor) {
engine.save();
engine.fillStyle = backgroundColor;
engine.globalCompositeOperation = SOURCE_OVER;
engine.globalAlpha = 1;
engine.fillRect(0, 0, width, height);
engine.restore();
}
else if (clearAlpha) {
engine.save();
const tempCell = requestCell(width, height);
const {engine:tempEngine, element:tempEl} = tempCell;
tempEngine.drawImage(element, 0, 0, width, height, 0, 0, width, height);
engine.clearRect(0, 0, width, height);
engine.globalAlpha = clearAlpha;
engine.drawImage(tempEl, 0, 0, width, height, 0, 0, width, height);
engine.restore();
releaseCell(tempCell);
}
else {
engine.clearRect(0, 0, width, height);
}
};