Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 1x 1x 1x 1x 1x 1x 527x 527x 1x 850x 850x 1x 7x 7x 1x 526x 526x 1x 1x 1x 1x | /*
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
*
* Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
* http://juerglehni.com/ & https://puckey.studio/
*
* Distributed under the MIT license. See LICENSE file for details.
*
* All rights reserved.
*/
// TODO: remove eslint-disable comment and deal with errors over time
/* eslint-disable */
import { ref } from '~/globals';
import { Group } from './Group';
/**
* @name 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
*/
export const Layer = Group.extend(
/** @lends Layer# */ {
_class: 'Layer',
// Turn on again for now, since examples depend on it.
// TODO: Discus with @puckey and come to a conclusion
// _selectChildren: false,
// DOCS: improve constructor code example.
/**
* Creates a new Layer item and places it at the end of the
* {@link Project#layers} array. The newly created layer will be activated,
* so all newly created items will be placed within it.
*
* @name Layer#initialize
* @param {Item[]} [children] An array of items that will be added to the
* newly created layer
*
* @example
* var layer = new Layer();
*/
/**
* Creates a new Layer item and places it at the end of the
* {@link Project#layers} array. The newly created layer will be activated,
* so all newly created items will be placed within it.
*
* @name Layer#initialize
* @param {Object} object an object containing the properties to be set on
* the layer
*
* @example {@paperscript}
* var path = new Path([100, 100], [100, 200]);
* var path2 = new Path([50, 150], [150, 150]);
*
* // Create a layer. The properties in the object literal
* // are set on the newly created layer.
* var layer = new Layer({
* children: [path, path2],
* strokeColor: 'black',
* position: view.center
* });
*/
initialize: function Layer() {
Group.apply(this, arguments);
},
/**
* Private helper to return the owner, either the parent, or the project
* for top-level layers, if they are inserted in it.
*/
_getOwner: function () {
return this._parent || (this._index != null && this._project);
},
isInserted: function isInserted() {
return this._parent ? (isInserted as any).base.call(this) : this._index != null;
},
/**
* Activates the layer.
*
* @example
* var firstLayer = project.activeLayer;
* var secondLayer = new Layer();
* console.log(project.activeLayer == secondLayer); // true
* firstLayer.activate();
* console.log(project.activeLayer == firstLayer); // true
*/
activate: function () {
this._project._activeLayer = this;
},
_hitTestSelf: function () {},
}
);
ref.Layer = Layer;
|