hammerspoon2-docs
    Preparing search index...

    Class HSColor

    Bridge type for working with colors in JavaScript

    Index
    • Update this color's value.

      If this color is bound to a UI element, the canvas re-renders automatically.

      Parameters

      • value: string | HSColor

        A hex color string (e.g. "#FF0000") or another HSColor object

      Returns void

    • Returns a plain object containing this color's sRGB components, for JSON serialisation

      JSON.stringify() calls this automatically, so you rarely need to call it yourself.

      Returns Record<string, any>

      An object with red, green, blue and alpha properties, each between 0.0 and 1.0, matching the arguments of HSColor.rgb()

    • Create a color from a hex string

      Parameters

      • hex: string

        Hex string (e.g. "#FF0000", "FF0000", "#F00", or "#FF000080" with alpha)

      Returns HSColor

      An HSColor object

    • Create a color from a named system color

      Parameters

      • name: string

        Name of the system color (e.g. "red", "blue", "systemBlue")

      Returns HSColor

      An HSColor object

    • Create a color from RGB values

      Parameters

      • r: number

        Red component (0.0-1.0)

      • g: number

        Green component (0.0-1.0)

      • b: number

        Blue component (0.0-1.0)

      • a: number

        Alpha component (0.0-1.0)

      Returns HSColor

      An HSColor object