Clear layers canvas before redraw

This commit is contained in:
jdescottes 2013-09-26 21:53:37 +02:00
parent 3a8d96f840
commit 50ca22d91a
2 changed files with 7 additions and 4 deletions

View File

@ -275,11 +275,13 @@
var serialized = [currentFrameIndex, this.piskelController.currentLayerIndex, layers.length].join("-");
if (this.serializedLayerFrame != serialized) {
this.layersUpRenderer.clear();
this.layersDownRenderer.clear();
var downLayers = layers.slice(0, currentLayerIndex);
var downFrame = this.getFrameForLayersAt_(currentFrameIndex, downLayers);
this.layersDownRenderer.render(downFrame);
// try {this.layersUpRenderer.clear();}catch(e) {}
if (currentLayerIndex + 1 < layers.length) {
var upLayers = layers.slice(currentLayerIndex + 1, layers.length);
var upFrame = this.getFrameForLayersAt_(currentFrameIndex, upLayers);

View File

@ -85,9 +85,10 @@
}
};
ns.FrameRenderer.prototype.clear = function (frame) {
var canvas = this.getCanvas_(frame);
canvas.getContext("2d").clearRect(0, 0, canvas.width, canvas.height);
ns.FrameRenderer.prototype.clear = function () {
if (this.canvas) {
this.canvas.getContext("2d").clearRect(0, 0, this.canvas.width, this.canvas.height);
}
};
/**