Doc: Change comment about using canvas.width = canvas.width instead of context.clearRect.

This commit is contained in:
Jonathan Puckey 2011-02-26 14:34:01 +01:00
parent 8cf2f54d5f
commit 1a6c5c8c6f

View file

@ -29,9 +29,10 @@ Doc = Base.extend({
redraw: function() {
if (this.canvas) {
// TODO: clearing the canvas by setting
// this.canvas.width = this.canvas.width might be faster..
this.ctx.clearRect(0, 0, this.size.width + 1, this.size.height);
// Initial tests conclude that clearing the canvas is always
// faster than using clearRect:
// http://jsperf.com/clearrect-vs-setting-width/7
this.ctx.clearRect(0, 0, this.size.width + 1, this.size.height + 1);
for (var i = 0, l = this.layers.length; i < l; i++) {
this.layers[i].draw(this.ctx, {});
}