Represents a color in AutoCAD, supporting various color formats.

AcCmColor

1.0.0

Constructors

Properties

NAMES: Record<string, number> = _colorKeywords

Accessors

  • get colorIndex(): null | number
  • Gets the AutoCAD color index value. The index value will be in the range 0 to 256. 0 and 256 are special values.

    Returns null | number

    The color index.

  • set colorIndex(value: null | number): void
  • Sets the AutoCAD color index value. If value less than 0 is set, 0 will be used. If value greater than 256 is set, 256 will be used.

    • 0 indicates that the entity uses the color of the BlockReference that's displaying it. If the entity is not displayed through a block reference (for example, it is directly owned by the model space block table record) and its color is 0, then it will display as though its color were 7.
    • 256 indicates that the entity uses the color specified in the layer table record it references.

    Parameters

    • value: null | number

      The color index to set (0-256).

    Returns void

  • get cssColor(): string
  • Gets the CSS RGB color string representation.

    Returns string

    The CSS RGB color string (e.g., "rgb(255,255,255)").

  • get hexColor(): string
  • Gets the hexadecimal representation of the current color.

    Returns string

    The hexadecimal color string (e.g., "0xFFFFFF").

Methods

  • Sets the color using RGB values.

    Parameters

    • r: number

      The red component (0-255).

    • g: number

      The green component (0-255).

    • b: number

      The blue component (0-255).

    Returns AcCmColor

    The current instance.