Skip to content

textmode.js / TextmodeImage

Class: TextmodeImage

Represents an image uploaded for textmode rendering via Textmodifier.loadImage.

It can be drawn to the canvas via Textmodifier.image.

An image uploaded currently runs through an adjustable brightness-converter that converts the original image into a textmode representation using characters. Those adjustable options are available via chainable methods on this class.

Accessors

height

Get Signature

ts
get height(): number;

Original pixel height of the source image.

Returns

number


texture

Get Signature

ts
get texture(): WebGLTexture;

WebGL texture handle containing the original source image.

Returns

WebGLTexture


width

Get Signature

ts
get width(): number;

Original pixel width of the source image.

Returns

number

Methods

background()

ts
background(
   r, 
   g?, 
   b?, 
   a?): this;

Set background color for transparent pixels.

Parameters

ParameterTypeDescription
rnumberRed channel (0-255)
g?numberGreen channel (0-255)
b?numberBlue channel (0-255)
a?numberAlpha channel (0-255)

Returns

this

This instance for chaining.


cellColor()

ts
cellColor(
   r, 
   g?, 
   b?, 
   a?): this;

Defines the cell color used when cellColorMode is 'fixed'.

Parameters

ParameterTypeDescription
rnumberRed channel (0-255)
g?numberGreen channel (0-255)
b?numberBlue channel (0-255)
a?number-

Returns

this

This instance for chaining.


cellColorMode()

ts
cellColorMode(mode): this;

Set the cell color mode: 'sampled' (from image) or 'fixed' (use cellColor).

Parameters

ParameterTypeDescription
mode"sampled" | "fixed"

Returns

this


characters()

ts
characters(chars): this;

Define the characters to use for brightness mapping as a string.

The maximum number of characters for brightness mapping currently is 64; excess characters are ignored.

Parameters

ParameterTypeDescription
charsstring

Returns

this


charColor()

ts
charColor(
   r, 
   g?, 
   b?, 
   a?): this;

Defines the character color used when charColorMode is 'fixed'.

Parameters

ParameterTypeDescription
rnumberRed channel (0-255)
g?numberGreen channel (0-255)
b?numberBlue channel (0-255)
a?number-

Returns

this

This instance for chaining.


charColorMode()

ts
charColorMode(mode): this;

Set character color mode: 'sampled' (from image) or 'fixed' (use charColor).

Parameters

ParameterTypeDescription
mode"sampled" | "fixed"

Returns

this


charRotation()

ts
charRotation(degrees): this;

Set the character rotation in degrees.

Parameters

ParameterTypeDescription
degreesnumberRotation in degrees (0-360)

Returns

this

This instance for chaining.


flipX()

ts
flipX(v): this;

Set horizontal flip indicator flag.

Parameters

ParameterTypeDefault valueDescription
vnumber | booleantrueFlag value

Returns

this

This instance for chaining.


flipY()

ts
flipY(v): this;

Set vertical flip indicator flag.

Parameters

ParameterTypeDefault valueDescription
vnumber | booleantrueFlag value

Returns

this

This instance for chaining.


invert()

ts
invert(v): this;

Set the invert flag.

Setting this flag to true will swap the character and cell colors when rendering the image.

Parameters

ParameterTypeDefault valueDescription
vnumber | booleantrueFlag value

Returns

this

This instance for chaining.