Allow CanvasProvider to receive sizes too.

This commit is contained in:
Jonathan Puckey 2011-02-24 01:29:51 +01:00
parent f1cd24eef8
commit dc51384a1a

View file

@ -1,15 +1,18 @@
CanvasProvider = { CanvasProvider = {
canvases: [], canvases: [],
getCanvas: function(width, height) { getCanvas: function() {
var size = Size.read(arguments);
var canvas = this.canvases.length var canvas = this.canvases.length
? this.canvases.pop() ? this.canvases.pop()
: document.createElement('canvas'); : document.createElement('canvas');
canvas.width = width; canvas.width = size.width;
canvas.height = height; canvas.height = size.height;
return canvas; return canvas;
}, },
returnCanvas: function(canvas) { returnCanvas: function(canvas) {
// reset canvas:
canvas.width = canvas.width;
this.canvases.push(canvas); this.canvases.push(canvas);
} }
}; };