mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-28 17:02:24 -05:00
Add a layer to the document's children list when created and support activeLayer.
This commit is contained in:
parent
c9c27f7be2
commit
31c51ea9eb
1 changed files with 12 additions and 7 deletions
19
src/Doc.js
19
src/Doc.js
|
@ -1,14 +1,19 @@
|
|||
Doc = Base.extend({
|
||||
initialize: function(canvas) {
|
||||
this.canvas = canvas;
|
||||
this.ctx = this.canvas.getContext('2d');
|
||||
this.size = new Size(canvas.offsetWidth, canvas.offsetHeight);
|
||||
this.children = [];
|
||||
if(canvas) {
|
||||
this.canvas = canvas;
|
||||
this.ctx = this.canvas.getContext('2d');
|
||||
this.size = new Size(canvas.offsetWidth, canvas.offsetHeight);
|
||||
}
|
||||
this.activeLayer = new Layer();
|
||||
this.children = this.activeLayer;
|
||||
},
|
||||
redraw: function() {
|
||||
this.ctx.clearRect(0, 0, this.size.width, this.size.height);
|
||||
for(var i = 0, l = this.children.length; i < l; i++) {
|
||||
this.children[i].draw(this.ctx);
|
||||
if(this.canvas) {
|
||||
this.ctx.clearRect(0, 0, this.size.width, this.size.height);
|
||||
for(var i = 0, l = this.children.length; i < l; i++) {
|
||||
this.children[i].draw(this.ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue