Skip to content

textmode.js / textmode

Class: textmode

The main entry point for the textmode.js library.

Provides static methods for creating Textmodifier instances and managing global settings.

Accessors

version

Get Signature

ts
get static version(): string;

Returns the version of textmode.js being used.

Example
javascript
console.log(textmode.version); // "1.0.0"
Returns

string

Methods

create()

ts
static create(opts): Textmodifier;

Create a new Textmodifier instance with optional configuration.

Parameters

ParameterTypeDescription
optsTextmodeOptionsConfiguration options for the Textmodifier instance

Returns

Textmodifier

A new Textmodifier instance

Example

javascript
// Create with default canvas
const textmodifier = textmode.create();

textmodifier.setup(() => {
  // Called when the Textmodifier is ready
  console.log(`Grid size: ${textmodifier.grid.cols}x${textmodifier.grid.rows}`);
});

textmodifier.draw(() => {
  textmodifier.background(128);
  textmodifier.rect(10, 10, 20, 20);
});

// Create with options
const textmodifier2 = textmode.create({ width: 1920, height: 1080 });

// Create with canvas and options
const textmodifier3 = textmode.create({ canvas: canvas, fontSize: 20 });

setErrorLevel()

ts
static setErrorLevel(level): void;

Set the global error handling level for the library. This applies to all Textmodifier instances present.

Parameters

ParameterTypeDescription
levelTextmodeErrorLevelThe error handling level to set.

Returns

void

Example

javascript
// Set error level to WARNING
textmode.setErrorLevel(TextmodeErrorLevel.WARNING);