LayerManager Class Reference

The LayerManager JavaScript class. Access the layers of a given panel. More...

Panel Layer Manipulation

int numberOfLayers (String &panelId)
 Return the number of layers in a panel. More...
 
bool addVectorLayer (String &panelId, int targetLayerIdx, bool before, String &suggestedName)
 Add a vector layer. More...
 
bool addBitmapLayer (String &panelId, int targetLayerIdx, bool before, String &suggestedName)
 Add a bitmap layer. More...
 
bool isVectorLayer (String &panelId, int index)
 Return true if a layer is a vector layer. More...
 
bool is3DLayer (String &panelId, int index)
 Return true if a layer is a 3D layer. More...
 
bool isBitmapLayer (String &panelId, int index)
 Return true if a layer is a bitmap. More...
 
bool deleteLayer (String &panelId, int index)
 Delete a given layer. More...
 
bool renameLayer (String &panelId, int index, String &suggestedName)
 Rename a given layer. More...
 
String layerName (String &panelId, int index)
 Return the name of a layer. More...
 
bool importImageAsLayer (String &panelId, String &fullPathAndFileName)
 Import image and creates a new layer at index 0, returns if successful. More...
 
bool setLayerVisible (String &panelId, int index, bool visible)
 Set the visibility flag of the layers of a panel. More...
 
bool layerVisibility (String &panelId, int index)
 Get the visibility flag of the layers of a panel. More...
 
bool setLayerOpacity (String &panelId, int index, double opacity)
 Set a layer's opacity. More...
 
double layerOpacity (String &panelId, int index)
 Get layers opacity value. More...
 
bool setLayerAlignment (String &panelId, int index, String &alignment)
 Set a layer's alignment value. More...
 
String layerAlignment (String &panelId, int index)
 Get a layer's alignment value. More...
 
String getLayerDrawingName (String &panelId, int index, bool fullPath)
 Get the path to a layer's drawing. More...
 
int getLayerElementId (String &panelId, int index)
 Return the element id of the layer. May be useful when using the element and Drawing global objects. More...
 
bool generateMatteLayer (String &panelId, int index, double radius, bool copyStrokes, bool replaceLayer)
 Generate a new drawing layer making a matte from the given layer. The matte will be of the current selected color. More...
 
bool generateMatteLayer (String &panelId, int index, double radius, bool copyStrokes, bool replaceLayer, unsigned int red, unsigned int green, unsigned int blue)
 Generate a new drawing layer making a matte from the given layer. The matte will be of the given color. More...
 
bool generateMatte (String &panelId, int index, QScriptValue options)
 Generate matte from a given layer to a new drawing layer or directly on the source layer. More...
 
bool isShared (QScriptValue layer)
 Look at the the given Layer and return if it is shared. More...
 
QScriptValue mergeLayers (QScriptValue layers, String &newLayerName)
 Merge the given Layers into a single panel. More...
 
bool isEmpty (QScriptValue layer)
 Look at the given layer and return if it is empty or not. A layer is empty if it has no drawing. More...
 

Detailed Description

The LayerManager JavaScript class. Access the layers of a given panel.

var lm = new LayerManager();
var sb = new StoryboardManager();
// get the first panel in the project.
var panelId = sb.panelInProject(0);
// Add 2 blank vector layers and 1 blank bitmap layer. Set the last one to invisible
lm.addVectorLayer( panelId, 0, false, "V-A");
lm.addVectorLayer( panelId, 1, false, "V-B");
lm.addBitmapLayer( panelId, 2, false, "B-A");
lm.setLayerVisible( panelId, 2, false);
// prepend a new layer by importing an image.
lm.importImageAsLayer(panelId, "/fullPath/Image.tga");

Member Function Documentation

◆ addBitmapLayer

bool LayerManager::addBitmapLayer ( String &  panelId,
int  targetLayerIdx,
bool  before,
String &  suggestedName 
)
slot

Add a bitmap layer.

Parameters
panelId- unique id of the panel
targetLayerIdx- index of sibling layer
before- whether new layer is before or after sibling layer
suggestedName- suggested Name

◆ addVectorLayer

bool LayerManager::addVectorLayer ( String &  panelId,
int  targetLayerIdx,
bool  before,
String &  suggestedName 
)
slot

Add a vector layer.

Parameters
panelId- unique id of the panel
targetLayerIdx- index of sibling layer
before- whether new layer is before or after sibling layer
suggestedName- suggested Name

◆ deleteLayer

bool LayerManager::deleteLayer ( String &  panelId,
int  index 
)
slot

Delete a given layer.

Parameters
panelId- uniqueId of the panel
index- index of the layer

◆ generateMatte

bool LayerManager::generateMatte ( String &  panelId,
int  index,
QScriptValue  options 
)
slot

Generate matte from a given layer to a new drawing layer or directly on the source layer.

Note
This method only works on vector layers.
Parameters
panelId- The unique id of the panel
index- The index of the layer
options- Options used to generate the matte. The option object has the following properties:
Property Type Description
onNewLayer bool When true, the matte is created on a new layer.
radius double The number of the frame.
copyStrokes bool (Optional) Set to true to copy source strokes on the new layer. Can only be used if onNewLayer is set to true as well.
replaceLayer bool (Optional) Set to true to replace a previously generated matte layer. Can only be used if onNewLayer is set to true as well.
color int or String (Optional) Colour used to create the matte. Can be an hex RGB value or a standard W3C colour keyword name in a string. If not specified, the current colour will be used.

◆ generateMatteLayer [1/2]

bool LayerManager::generateMatteLayer ( String &  panelId,
int  index,
double  radius,
bool  copyStrokes,
bool  replaceLayer 
)
slot

Generate a new drawing layer making a matte from the given layer. The matte will be of the current selected color.

Note
This method only works on vector layers.
Parameters
panelId- The unique id of the panel
index- The index of the layer
radius- The matte radius
copyStrokes- Set to true to copy the strokes
replaceLayer- Set to true to replace the existing layer by one with the same name, false to keep both
Returns
True if a matte layer is created.

◆ generateMatteLayer [2/2]

bool LayerManager::generateMatteLayer ( String &  panelId,
int  index,
double  radius,
bool  copyStrokes,
bool  replaceLayer,
unsigned int  red,
unsigned int  green,
unsigned int  blue 
)
slot

Generate a new drawing layer making a matte from the given layer. The matte will be of the given color.

Note
This method only works on vector layers.
Parameters
panelId- The unique id of the panel
index- The index of the layer
radius- The matte radius
copyStrokes- Set to true to copy the strokes
replaceLayer- Set to true to replace the existing layer by one with the same name, false to keep both
red- The red channel value (0..255) for the matte. A value higher than 255 will be clamped.
green- The green channel value (0..255) for the matte. A value higher than 255 will be clamped.
blue- The blue channel value (0..255) for the matte. A value higher than 255 will be clamped.
Returns
True if a matte layer is created.

◆ getLayerDrawingName

String LayerManager::getLayerDrawingName ( String &  panelId,
int  index,
bool  fullPath 
)
slot

Get the path to a layer's drawing.

Parameters
panelId- unique id of the panel
index- index of the layer
fullPath- boolean to determine if the returned path is the full path or the file name

◆ getLayerElementId

int LayerManager::getLayerElementId ( String &  panelId,
int  index 
)
slot

Return the element id of the layer. May be useful when using the element and Drawing global objects.

Parameters
panelId- unique id of the panel
index- index of the layer

◆ importImageAsLayer

bool LayerManager::importImageAsLayer ( String &  panelId,
String &  fullPathAndFileName 
)
slot

Import image and creates a new layer at index 0, returns if successful.

Parameters
panelId- unique id of the panel
fullPathAndFileName- absolute path to image file

◆ is3DLayer

bool LayerManager::is3DLayer ( String &  panelId,
int  index 
)
slot

Return true if a layer is a 3D layer.

Parameters
panelId- unique id of the panel
index- index of the layer

◆ isBitmapLayer

bool LayerManager::isBitmapLayer ( String &  panelId,
int  index 
)
slot

Return true if a layer is a bitmap.

Parameters
panelId- unique id of the panel
index- index of the layer

◆ isEmpty

bool LayerManager::isEmpty ( QScriptValue  layer)
slot

Look at the given layer and return if it is empty or not. A layer is empty if it has no drawing.

Parameters
layer- an object with the name [String] and panelId properties [String].
Returns
True if the layer is empty, false if it isn't.

◆ isShared

bool LayerManager::isShared ( QScriptValue  layer)
slot

Look at the the given Layer and return if it is shared.

Parameters
layera layer is defined by those properties: frame, panelId, name.
Returns
True if the given layer is shared.

◆ isVectorLayer

bool LayerManager::isVectorLayer ( String &  panelId,
int  index 
)
slot

Return true if a layer is a vector layer.

Parameters
panelId- unique id of the panel
index- index of the layer

◆ layerAlignment

String LayerManager::layerAlignment ( String &  panelId,
int  index 
)
slot

Get a layer's alignment value.

Parameters
panelId- unique id of the panel
index- index of the layer

◆ layerName

String LayerManager::layerName ( String &  panelId,
int  index 
)
slot

Return the name of a layer.

Parameters
panelId- unique id of the panel
index- index of the layer

◆ layerOpacity

double LayerManager::layerOpacity ( String &  panelId,
int  index 
)
slot

Get layers opacity value.

Parameters
panelId- unique id of the panel
index- index of the layer

◆ layerVisibility

bool LayerManager::layerVisibility ( String &  panelId,
int  index 
)
slot

Get the visibility flag of the layers of a panel.

Parameters
panelId- unique id of the panel
index- index of the layer

◆ mergeLayers

QScriptValue LayerManager::mergeLayers ( QScriptValue  layers,
String &  newLayerName 
)
slot

Merge the given Layers into a single panel.

Parameters
layers- an array of objects with the name [String] and panelId properties [String].
newLayerName- new name of the layer created from the merge.
Returns
A single layer from the merge.

◆ numberOfLayers

int LayerManager::numberOfLayers ( String &  panelId)
slot

Return the number of layers in a panel.

Parameters
panelId- unique id of the panel

◆ renameLayer

bool LayerManager::renameLayer ( String &  panelId,
int  index,
String &  suggestedName 
)
slot

Rename a given layer.

Parameters
panelId- unique id of the panel
index- index of the layer
suggestedName- suggested name

◆ setLayerAlignment

bool LayerManager::setLayerAlignment ( String &  panelId,
int  index,
String &  alignment 
)
slot

Set a layer's alignment value.

Parameters
panelId- unique id of the panel
index- index of the layer
alignment- value between 0 and 100

◆ setLayerOpacity

bool LayerManager::setLayerOpacity ( String &  panelId,
int  index,
double  opacity 
)
slot

Set a layer's opacity.

Parameters
panelId- unique id of the panel
index- index of the layer
opacity- value between 0 and 100

◆ setLayerVisible

bool LayerManager::setLayerVisible ( String &  panelId,
int  index,
bool  visible 
)
slot

Set the visibility flag of the layers of a panel.

Parameters
panelId- unique id of the panel
index- index of the layer
visible- boolean flag