paper.js/src/util/CanvasProvider.js

18 lines
365 B
JavaScript
Raw Normal View History

CanvasProvider = {
canvases: [],
getCanvas: function(size) {
var canvas = this.canvases.length
? this.canvases.pop()
: document.createElement('canvas');
canvas.width = size.width;
canvas.height = size.height;
return canvas;
},
returnCanvas: function(canvas) {
// reset canvas:
canvas.width = canvas.width;
this.canvases.push(canvas);
}
};