Layer script interface

The ILayer script interface represents a layer on a layout.

Layer APIs

A read-only string of the layer name.
A read-only number with the zero-based index of the layer on its layout. The bottom layer has an index of 0, with the index increasing upwards in Z order.
The ILayout interface representing the layout this layer belongs to.
A reference to the layer's parent ILayer if it is a sub-layer, else null if it is a top-level layer.
Iterates all the layer's parent layers, moving up towards the top of the hierarchy.
Iterates the layer's own sub-layers in increasing Z order. This does not iterate any sub-layers at lower levels in the hierarchy.
Iterates the layer's sub-layers and further sub-layers beneath those recursively, in increasing Z order.
A boolean indicating if the layer is interactive, allowing its content to respond to mouse and touch input.
A read-only boolean indicating if both this layer and all its parent layers are set to be interactive. If this is true the layer content will respond to mouse and touch input.
A boolean indicating if the layer is visible. When invisible, the layer skips drawing entirely.
A read-only boolean indicating if both this layer and all its parent layers are set to visible. If this is true the layer will be drawn.
A boolean indicating if the layer background is transparent. When transparent, the background color is ignored.
Set or get the background color of a layer as an array with 3 elements specifying the red, green and blue components with values in the 0-1 range. Note this is ignored if the layer is transparent.
scrollTo(x, y)
Independently scroll a layer, regardless of where the layout is scrolled to. By default layers all follow the layout scroll position. Upon setting a layer's scroll position, the layer will stop following the layout scroll position, and remain scrolled at the position specified. The restoreScrollPosition() method reverts the layer to the default mode where it follows the layout scroll position. When not independently scrolling a layer, the scrollX and scrollY getters return the layout scroll position.
Set or get the horizontal and vertical parallax rates of a layer.
The opacity of the layer, as a floating point number in the range [0, 1], where 0 is fully transparent and 1 is fully opaque. Note that changing the opacity to a value other than 1 will force the layer to render via its own texture.
Set or get the layer scale, taking in to account its scale rate property.
Set or get the scale rate property of a layer, which affects how quickly it scales (if at all).
Set or get the layer angle in radians.
Set or get the Z elevation of the entire layer. By default the camera is at Z = 100, and looking down to Z = 0. The default Z elevation is 0. Increasing it will move the layer upwards (towards the camera) and decreasing it will move it downwards (away from the camera).
Return a DOMRect representing the bounds of the viewport on this layer in layout co-ordinates.
A boolean indicating the layer's Force own texture property. For more information see the property in the Layers manual entry.
A string indicating the blend mode of the layer, controlling how it draws over the other layers behind it. This must be one of "normal", "additive", "copy", "destination-over", "source-in", "destination-in", "source-out", "destination-out", "source-atop", "destination-atop".
An array of IEffectInstance representing the effect parameters of the effects on this layer.
cssPxToLayer(clientX, clientY, z = 0)
layerToCssPx(layerX, layerY, z = 0)
Convert between positions in CSS pixels, such as the clientX/Y properties of an input event, and layer co-ordinates within the project. An optional Z value can be provided to do the conversion taking in to account Z elevation to a certain height on the layer. This is useful for purposes like identifying what position in a layer was clicked in an input event, or positioning a HTML element in layer co-ordinates. Both methods return a pair of co-ordinates in the form [x, y].
Construct 3 Manual 2022-02-28

On this page