new Vecta.Layer([id])
Creates a new layer or gets existing layer.
Name | Type | Attributes | Description |
---|---|---|---|
id | string | optional | Null or undefined to create a new layer, otherwise a valid ID string to get the layer |
Examples:
var layer = new Vecta.Layer(); //creates a new layer called 'Untitled Layer'
Methods
.delete(keep)
Deletes the layer.
Name | Type | Description |
---|---|---|
keep | boolean | Set true to move all shapes to the default layer, false to remove all shapes. |
.hidden([state]) Returns: boolean|Vecta.Layer
Get or set visibility of the layer.
Name | Type | Attributes | Description |
---|---|---|---|
state | boolean | optional | Undefined to get current visibility, true to set hidden and false to set to visible. |
Returns:
Returns current visibility when get, or Vecta.Layer object when set.
.index([idx]) Returns: number|Vecta.Layer
Get or set layer index for z-ordering
Name | Type | Attributes | Description |
---|---|---|---|
idx | number | optional | Undefined to get the layer index, a number to set |
Returns:
Return the index when get or Vecta.Layer object when set
.json([json]) Returns: object|Vecta.Layer
Get or set the layer data in json format
Name | Type | Attributes | Description |
---|---|---|---|
json | object | optional | Accept an object to store, if not provided, return stored json data |
Returns:
Returns the json data when get or Vecta.Layer object when set
.name([name]) Returns: string|Vecta.Layer
Get or set layer name.
Name | Type | Attributes | Description |
---|---|---|---|
name | string | optional | Undefined to get the layer name, a string to set |
Returns:
Returns the name when get or Vecta.Layer object when set.
.print([state]) Returns: boolean|Vecta.Layer
Get or set layer to be included in export and/or print.
Name | Type | Attributes | Description |
---|---|---|---|
state | boolean | optional | Undefined to get, true to include in export and/or print, false to exclude. |
Returns:
Returns true to include in export and/or print, false to exclude when get, or Vecta.Layer when set.
.publish([state]) Returns: boolean|Vecta.Layer
Set layer to show or hide when a drawing is published. Also gets published status of layer.
Name | Type | Attributes | Description |
---|---|---|---|
state | boolean | optional | Undefined to get, true to include in published drawing, false to exclude. |
Returns:
Returns true to include in published drawing, false to exclude when get, or Vecta.Layer when set.
.select() Returns: Vecta.Layer
Select all shapes in the layer.
Examples:
var layer = new Vecta.Layer('#my_layer');
layer.select();
console.log(Vecta.selection.shapes()); //outputs all shapes in layer