Skip to content

textmode.js / Textmodifier / color

Method: color()

Call Signature

ts
color(gray, alpha?): TextmodeColor;

Create a reusable color object from a grayscale value.

Parameters

ParameterTypeDescription
graynumberGrayscale value (0-255)
alpha?numberOptional alpha value (0-255)

Returns

TextmodeColor

A TextmodeColor instance

Example

Call Signature

ts
color(
   r, 
   g, 
   b, 
   a?): TextmodeColor;

Create a reusable color object from RGB(A) values.

Parameters

ParameterTypeDescription
rnumberRed component (0-255)
gnumberGreen component (0-255)
bnumberBlue component (0-255)
a?numberOptional alpha component (0-255)

Returns

TextmodeColor

A TextmodeColor instance

Example

Call Signature

ts
color(value): TextmodeColor;

Create a reusable color object from a CSS string or existing TextmodeColor.

Accepts hex strings (e.g. '#FF0000') and rgb()/rgba() strings. Note: Named CSS colors (e.g., 'red', 'blue') are not supported.

Parameters

ParameterTypeDescription
value| string | TextmodeColorHex string, rgb()/rgba() string, or an existing color object

Returns

TextmodeColor

A TextmodeColor instance

Example