mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Implement CanvasProvider that provides reusable canvas elements.
This commit is contained in:
parent
3cd680c5f0
commit
6fcdb86e1c
1 changed files with 16 additions and 0 deletions
16
src/util/CanvasProvider.js
Normal file
16
src/util/CanvasProvider.js
Normal 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);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue