Implement CanvasProvider that provides reusable canvas elements.

This commit is contained in:
Jonathan Puckey 2011-02-21 03:17:09 +01:00
parent 3cd680c5f0
commit 6fcdb86e1c

View file

@ -0,0 +1,16 @@
CanvasProvider = {
canvases: [],
getCanvas: function(width, height) {
var canvas = this.canvases.length
? this.canvases.pop()
: document.createElement('canvas');
var cleared;
canvas.width = width;
canvas.height = height;
return canvas;
},
returnCanvas: function(canvas) {
this.canvases.push(canvas);
}
};