x4js - v2.2.49
    Preparing search index...

    Class Color

    Index
    • Creates a new Color instance from a string.

      Parameters

      • value: string

        The color string (e.g. "#ff0000", "rgb(255,0,0)").

      Returns Color

    • Creates a new Color instance from RGB values.

      Parameters

      • r: number

        Red component (0-255).

      • g: number

        Green component (0-255).

      • b: number

        Blue component (0-255).

      • Optionala: number

        Alpha component (0-1).

      Returns Color

    • Gets the alpha (transparency) value of the color.

      Returns number

      The alpha value (0-1).

    • Checks if the color is invalid (e.g. failed parsing).

      Returns boolean

      True if the color is invalid, false otherwise.

    • Lightens the color by a given percentage.

      Parameters

      • percent: number

        The percentage to lighten (0-100).

      Returns this

      The current Color instance.

    • Sets the alpha (transparency) value of the color.

      Parameters

      • a: number

        The new alpha value (0-1).

      Returns this

      The current Color instance.

    • Sets the color using HSV (Hue, Saturation, Value) components.

      Parameters

      • h: number

        Hue (0-1).

      • s: number

        Saturation (0-1).

      • v: number

        Value (0-1).

      • a: number = 1.0

        Alpha (0-1, default 1.0).

      Returns this

      The current Color instance.

    • Sets the color using RGB (Red, Green, Blue) components.

      Parameters

      • r: number

        Red component (0-255).

      • g: number

        Green component (0-255).

      • b: number

        Blue component (0-255).

      • a: number

        Alpha component (0-1).

      Returns this

      The current Color instance.

    • accepts: #aaa #ababab #ababab55 rgb(a,b,c) rgba(a,b,c,d) var( --color-5 ) cyan transparent

      Parameters

      • value: string

      Returns this

    • Returns the Hex string representation of the color.

      Returns string

      The hex color string (e.g. "#ff0000" or "#ff000080").

    • Converts the color to HSV representation.

      Returns Hsv

      An object containing hue, saturation, value, and alpha properties.

    • Returns the CSS string representation of the color.

      Parameters

      • OptionalwithAlpha: boolean

        Whether to include the alpha channel (default: true if alpha < 1).

      Returns string

      The CSS color string (e.g. "rgb(255,0,0)" or "rgba(255,0,0,0.5)").