Represents a color in AutoCAD, supporting various color formats.

AcCmColor

1.0.0

Constructors

  • Constructs a new AcCmColor instance. Initializes the color to "ByLayer" (index 256) and null RGB values.

    Returns AcCmColor

Properties

NAMES: Record<string, number>

Accessors

  • get blue(): null | number
  • Gets the blue component of the current color.

    Returns null | number

    The blue component (0-255).

  • get color(): null | number
  • Gets the current color value.

    Returns null | number

    The color value (RGB or index).

  • set color(value: null | number): void
  • Sets the color value.

    Parameters

    • value: null | number

      The color value to set (RGB or index).

    Returns void

  • 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 colorName(): null | string
  • Gets the name of the current color.

    Returns null | string

    The color name.

  • set colorName(value: null | string): void
  • Sets the color by name.

    Parameters

    • value: null | string

      The color name to set.

    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 green(): null | number
  • Gets the green component of the current color.

    Returns null | number

    The green component (0-255).

  • get hasColorIndex(): boolean
  • Checks if the color has an index.

    Returns boolean

    True if the color has no index, false otherwise.

  • get hasColorName(): boolean
  • Checks if the color has a name.

    Returns boolean

    True if the color has no name, false otherwise.

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

    Returns string

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

  • get isByBlock(): boolean
  • Checks if the color is set to "ByBlock".

    Returns boolean

    True if the color is "ByBlock", false otherwise.

  • get isByLayer(): boolean
  • Checks if the color is set to "ByLayer".

    Returns boolean

    True if the color is "ByLayer", false otherwise.

  • get red(): null | number
  • Gets the red component of the current color.

    Returns null | number

    The red component (0-255).

Methods

  • Clones the current AcCmColor instance.

    Returns this

    A new AcCmColor instance with the same color and index.

  • Copies the color from another AcCmColor instance.

    Parameters

    Returns this

    The current instance.

  • Checks if two AcCmColor instances are equal.

    Parameters

    Returns boolean

    True if the colors and their indices are the same.

  • Sets the color to "ByBlock".

    Returns this

    The current instance.

  • Sets the color to "ByLayer".

    Returns this

    The current instance.

  • Sets the color by name.

    Parameters

    • style: string

      The color name to set.

    Returns this

    The current instance.

  • 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 this

    The current instance.

  • Sets the color using a scalar value (RGB).

    Parameters

    • scalar: number

      The scalar value (0-255).

    Returns this

    The current instance.

  • Returns a string representation of the color.

    Returns string

    The color name or hexadecimal string.