Create a new MTextColor instance.
Optionalcolor: number | RGB | nullThe initial color: number for ACI, [r,g,b] for RGB, or null/undefined for default (ACI=256).
Get the current ACI color value.
The ACI color (0-256), or null if using RGB.
Returns true if the color is set by ACI, false if by RGB.
Returns true if the color is set by RGB, false if by ACI.
Get the current RGB color as a tuple [r, g, b], or null if not set.
The RGB color tuple, or null if using ACI.
Set the RGB color. Setting this disables ACI color.
The RGB color tuple [r, g, b], or null to use ACI.
Get or set the internal RGB value as a number (0xRRGGBB), or null if not set. Setting this will switch to RGB mode and set ACI to null.
Returns a deep copy of this color.
A new MTextColor instance with the same color state.
Equality check for color.
The other MTextColor to compare.
True if both ACI and RGB values are equal.
Convert the current color to a CSS hex color string (#rrggbb). Returns null if the color is ACI-based and has no RGB value.
Returns a plain object for serialization.
An object with aci, rgb (tuple), and rgbValue (number or null).
StaticfromCreate an MTextColor from a CSS color string. Supports #rgb, #rrggbb, rgb(...), rgba(...). Returns null if invalid or transparent.
Class to handle ACI and RGB color logic for MText.
This class encapsulates color state for MText, supporting both AutoCAD Color Index (ACI) and RGB color. Only one color mode is active at a time: setting an RGB color disables ACI, and vice versa. RGB is stored as a single 24-bit integer (0xRRGGBB) for efficient comparison and serialization.
Example usage: