Class: Layer

Layer(stage, source, geometry, view, textureStore, opts)

A Layer is a combination of Source, Geometry, View and TextureStore that may be added into a Stage and rendered with Effects.

Constructor

new Layer(stage, source, geometry, view, textureStore, opts)

Parameters:
Name Type Description
stage Stage
source Source
geometry Geometry
view View
textureStore TextureStore
opts Object
Properties
Name Type Description
effects Effects

Methods

destroy()

Destructor.

effects() → {Effects}

Returns the currently set effects.

Returns:
Type
Effects

fixedLevel() → {number|null}

Returns the fixed level index.

Returns:
Type
number | null

geometry() → {Geometry}

Returns the underlying geometry.

Returns:
Type
Geometry

mergeEffects(effects)

Merges effects into the currently set ones. The merge is non-recursive; for instance, if current effects are { rect: { relativeWidth: 0.5 } }, calling this method with { rect: { relativeX: 0.5 }} will reset rect.relativeWidth.

Parameters:
Name Type Description
effects Effects

pinFirstLevel()

Pin the first level. Equivalent to pinLevel(0).

pinLevel(levelIndex)

Pin a whole level into the texture store.

Parameters:
Name Type Description
levelIndex Number

setEffects(effects)

Sets the effects.

Parameters:
Name Type Description
effects Effects

setFixedLevel(levelIndex)

Sets the fixed level index. When set, the corresponding level will be used regardless of the view parameters. Unset with a null argument.

Parameters:
Name Type Description
levelIndex number | null
Throws:

An error if the level index is out of range.

source() → {Source}

Returns the underlying source.

Returns:
Type
Source

stage() → {Stage}

Returns the underlying stage.

Returns:
Type
Stage

textureStore() → {TextureStore}

Returns the underlying texture store.

Returns:
Type
TextureStore

unpinFirstLevel()

Unpin the first level. Equivalent to unpinLevel(0).

unpinLevel(levelIndex)

Unpin a whole level from the texture store.

Parameters:
Name Type Description
levelIndex Number

view() → {View}

Returns the underlying view.

Returns:
Type
View