Skip to content

textmode.js / layering / TextmodeLayerManager

Class: TextmodeLayerManager

Manages all user-defined layers within a Textmodifier in addition to the base layer.

This manager is responsible for:

  • Managing the collection of user layers (add, remove, move, swap)
  • Coordinating layer rendering and compositing

The instance of this class can be accessed via Textmodifier.layers.

The base layer is not part of the public layer stack, but is instead managed internally.

Implements

  • ILayerManager

Accessors

all

Get Signature

ts
get all(): readonly TextmodeLayer[];

Get all user layers as a readonly array.

Returns

readonly TextmodeLayer[]

Implementation of

ts
ILayerManager.all

base

Get Signature

ts
get base(): TextmodeLayer;

The base layer that is always rendered at the bottom of the layer stack. This layer represents the main drawing content before any user layers are composited.

Returns

TextmodeLayer

Implementation of

ts
ILayerManager.base

Methods

add()

ts
add(options): TextmodeLayer;

Add a new layer to the manager.

Parameters

ParameterTypeDescription
optionsTextmodeLayerOptionsLayer configuration options.

Returns

TextmodeLayer

The newly added layer.

Implementation of

ts
ILayerManager.add

clear()

ts
clear(): void;

Remove all user-created layers from the manager. The base layer is not affected by this operation. This is useful for integration into live-coding environments where code is re-evaluated and layers need to be recreated from scratch.

Returns

void

Implementation of

ts
ILayerManager.clear

move()

ts
move(layer, newIndex): void;

Move a layer to a new index in the layer stack.

Parameters

ParameterTypeDescription
layerTextmodeLayerThe layer to move.
newIndexnumberThe new index for the layer.

Returns

void

Implementation of

ts
ILayerManager.move

remove()

ts
remove(layer): void;

Remove a layer from the manager.

Parameters

ParameterTypeDescription
layerTextmodeLayerThe layer to remove.

Returns

void

Implementation of

ts
ILayerManager.remove

swap()

ts
swap(layerA, layerB): void;

Swap the order of two layers if they exist in the same collection.

Parameters

ParameterTypeDescription
layerATextmodeLayerThe first layer to swap.
layerBTextmodeLayerThe second layer to swap.

Returns

void

Implementation of

ts
ILayerManager.swap