Utility class for AutoCAD color operations.

Constructors

Methods

  • Returns the RGB color value for a given AutoCAD color index.

    Parameters

    • index: number

      The AutoCAD color index value (0-255).

    Returns number

    The RGB color value as a 24-bit integer.

    // Get the RGB value for color index 1 (red)
    const redColor = AcCmColorUtil.getAcadColor(1); // returns 16711680 (0xFF0000)
    // Get special inheritance colors
    const byBlock = AcCmColorUtil.getAcadColor(0); // "ByBlock" color
    const byLayer = AcCmColorUtil.getAcadColor(256); // "ByLayer" color
  • Returns the RGB color value for a given CSS color name.

    Parameters

    • name: string

      The CSS color name (e.g., "red", "blue", "aliceblue").

    Returns number

    The RGB color value as a 24-bit integer, or undefined if the name is not found.

    // Get the RGB value for a standard color name
    const redColor = AcCmColorUtil.getColorByName("red"); // returns 16711680 (0xFF0000)
    const blueColor = AcCmColorUtil.getColorByName("blue"); // returns 255 (0x0000FF)
    // Handle undefined for unknown color names
    const unknownColor = AcCmColorUtil.getColorByName("unknown"); // returns undefined
  • Finds the color name associated with a given RGB value.

    Parameters

    • rgb: number

      The RGB value to find a name for.

    Returns undefined | string

    The color name if found, undefined otherwise.

  • Finds the color name associated with a given color index.

    Parameters

    • index: number

      The color index to find a name for.

    Returns undefined | string

    The color name if found, undefined otherwise.