textmode.js / Textmodifier / color
Method: color()
Call Signature
ts
color(gray, alpha?): TextmodeColor;Create a reusable color object from a grayscale value.
Parameters
| Parameter | Type | Description |
|---|---|---|
gray | number | Grayscale value (0-255) |
alpha? | number | Optional alpha value (0-255) |
Returns
A TextmodeColor instance
Example
Call Signature
ts
color(
r,
g,
b,
a?): TextmodeColor;Create a reusable color object from RGB(A) values.
Parameters
| Parameter | Type | Description |
|---|---|---|
r | number | Red component (0-255) |
g | number | Green component (0-255) |
b | number | Blue component (0-255) |
a? | number | Optional alpha component (0-255) |
Returns
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
| Parameter | Type | Description |
|---|---|---|
value | | string | TextmodeColor | Hex string, rgb()/rgba() string, or an existing color object |
Returns
A TextmodeColor instance