diff --git a/src/util/CanvasProvider.js b/src/util/CanvasProvider.js new file mode 100644 index 00000000..bcced6d7 --- /dev/null +++ b/src/util/CanvasProvider.js @@ -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); + } +};