Skip to main content

Class: P5AsciifierManager

Defined in: AsciifierManager.ts:19

Manages the p5.asciify library by handling one or more P5Asciifier instances.

This class is implemented as a singleton, meaning only one instance exists throughout the application. Access the instance through the exposed p5asciify object or via P5AsciifierManager.getInstance.

The manager is responsible for:

  • Initializing ASCII rendering capabilities
  • Managing multiple asciifier instances
  • Coordinating with p5.js rendering lifecycle
  • Providing an API for creating, accessing, and removing asciifiers

Accessors

asciifiers

Get Signature

get asciifiers(): P5Asciifier[]

Defined in: AsciifierManager.ts:192

Returns the list of P5Asciifier instances managed by the library.

Returns

P5Asciifier[]

Methods

add()

add(framebuffer?): P5Asciifier

Defined in: AsciifierManager.ts:137

Adds a new P5Asciifier instance to the library.

Parameters

ParameterTypeDescription
framebuffer?anyThe framebuffer to capture for ASCII conversion. If not provided, the main canvas of the p5.js instance will be used.

Returns

P5Asciifier

The newly created P5Asciifier instance.

Throws

P5AsciifyError If the framebuffer is not an instance of p5.Framebuffer.


asciifier()

asciifier(index): P5Asciifier

Defined in: AsciifierManager.ts:122

Returns the P5Asciifier instance at the specified index.

When passing no arguments, the method returns the first P5Asciifier instance in the list, which usually corresponds to the default P5Asciifier provided by the library, which is applied to the main canvas of the p5.js instance.

Parameters

ParameterTypeDefault valueDescription
indexnumber0The index of the P5Asciifier instance to return.

Returns

P5Asciifier

The P5Asciifier instance at the specified index.

Throws

P5AsciifyError If the index is out of bounds.


remove()

remove(indexOrAsciifier): void

Defined in: AsciifierManager.ts:159

Removes a P5Asciifier instance.

Parameters

ParameterTypeDescription
indexOrAsciifiernumber | P5AsciifierThe index of the P5Asciifier instance to remove, or the P5Asciifier instance itself.

Returns

void

Throws

P5AsciifyError If the index is out of bounds or the specified asciifier is not found.


getInstance()

static getInstance(): P5AsciifierManager

Defined in: AsciifierManager.ts:44

Gets the singleton instance of P5AsciifierManager. If the instance doesn't exist yet, it creates one.

Returns

P5AsciifierManager

The singleton instance of P5AsciifierManager.