Layer

Vecta.Layer

new Vecta.Layer([id])

Creates a new layer or gets existing layer.

NameTypeAttributesDescription
idstringoptional

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.

NameTypeDescription
keepboolean

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.

NameTypeAttributesDescription
statebooleanoptional

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

NameTypeAttributesDescription
idxnumberoptional

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

NameTypeAttributesDescription
jsonobjectoptional

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.

NameTypeAttributesDescription
namestringoptional

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.

NameTypeAttributesDescription
statebooleanoptional

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.

NameTypeAttributesDescription
statebooleanoptional

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
Capital™ Electra™ X