mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -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({
|
Doc = Base.extend({
|
||||||
initialize: function(canvas) {
|
initialize: function(canvas) {
|
||||||
this.canvas = canvas;
|
if(canvas) {
|
||||||
this.ctx = this.canvas.getContext('2d');
|
this.canvas = canvas;
|
||||||
this.size = new Size(canvas.offsetWidth, canvas.offsetHeight);
|
this.ctx = this.canvas.getContext('2d');
|
||||||
this.children = [];
|
this.size = new Size(canvas.offsetWidth, canvas.offsetHeight);
|
||||||
|
}
|
||||||
|
this.activeLayer = new Layer();
|
||||||
|
this.children = this.activeLayer;
|
||||||
},
|
},
|
||||||
redraw: function() {
|
redraw: function() {
|
||||||
this.ctx.clearRect(0, 0, this.size.width, this.size.height);
|
if(this.canvas) {
|
||||||
for(var i = 0, l = this.children.length; i < l; i++) {
|
this.ctx.clearRect(0, 0, this.size.width, this.size.height);
|
||||||
this.children[i].draw(this.ctx);
|
for(var i = 0, l = this.children.length; i < l; i++) {
|
||||||
|
this.children[i].draw(this.ctx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
Loading…
Reference in a new issue