mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Add Layer documentation.
This commit is contained in:
parent
ca35b3fe60
commit
59af5343b5
1 changed files with 35 additions and 1 deletions
|
@ -15,8 +15,33 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Layer = this.Layer = Group.extend({
|
var Layer = this.Layer = Group.extend({
|
||||||
beans: true,
|
/** @lends Layer# */
|
||||||
|
|
||||||
|
beans: true,
|
||||||
|
|
||||||
|
// DOCS: improve constructor code example.
|
||||||
|
/**
|
||||||
|
* Creates a new Layer item and places it at the end of the
|
||||||
|
* {@link Project#layers} array.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* var layer = new Layer();
|
||||||
|
* layer.name = 'the new layer';
|
||||||
|
*
|
||||||
|
* @param {array} [children] An optional array of children that will be
|
||||||
|
* added to the newly created layer.
|
||||||
|
*
|
||||||
|
* @class The Layer item represents a layer in a Paper.js project.
|
||||||
|
*
|
||||||
|
* The layer which is currently active can be accessed through
|
||||||
|
* {@link Project#activeLayer}.
|
||||||
|
* An array of all layers in a project can be accessed through
|
||||||
|
* {@link Project#layers}.
|
||||||
|
*
|
||||||
|
* @extends Group
|
||||||
|
* @extends Item
|
||||||
|
* @constructs Layer
|
||||||
|
*/
|
||||||
initialize: function(items) {
|
initialize: function(items) {
|
||||||
this._project = paper.project;
|
this._project = paper.project;
|
||||||
// Push it onto project.layers and set index:
|
// Push it onto project.layers and set index:
|
||||||
|
@ -44,6 +69,15 @@ var Layer = this.Layer = Group.extend({
|
||||||
: this._project.layers[this._index - 1] || null;
|
: this._project.layers[this._index - 1] || null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activates the layer.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* var layer = new Layer();
|
||||||
|
* layer.name = 'new layer';
|
||||||
|
* layer.activate();
|
||||||
|
* console.log(project.activeLayer.name) // 'new layer'
|
||||||
|
*/
|
||||||
activate: function() {
|
activate: function() {
|
||||||
this._project.activeLayer = this;
|
this._project.activeLayer = this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue