Color information and functionality. Colors are stored in RGBA format.

Constructors

Accessors

  • get alpha(): number
  • Returns number

    The current alpha component value (0-255).

  • set alpha(a): void
  • Set the value of the alpha component.

    Parameters

    • a: number

    Returns void

  • get blue(): number
  • Returns number

    The current blue component value (0-255).

  • set blue(b): void
  • Set the value of the blue component.
    IMPORTANT: This method will set _name to null.

    Parameters

    • b: number

    Returns void

  • get color(): Color
  • Returns Color

    A p5.js Color object matching the current red, green, blue, and alpha values.

  • set color(c): void
  • Set the current color.
    IMPORTANT: This method will set _name to null.

    Parameters

    Returns void

  • get green(): number
  • Returns number

    The current green component value (0-255).

  • set green(g): void
  • Set the value of the green component.
    IMPORTANT: This method will set _name to null.

    Parameters

    • g: number

    Returns void

  • get hex(): string
  • Returns string

    The hex color string for the RGB (red, green, blue) components of the color (#RRGGBB).

  • get name(): string
  • Returns string

    The name of the color.

  • get red(): number
  • Returns number

    The current red component value (0-255).

  • set red(r): void
  • Set the value of the red component.
    IMPORTANT: This method will set _name to null.

    Parameters

    • r: number

    Returns void

Methods

  • Parameters

    • h: number

      Some number between 0 and 360.

    • s: number

      Some number between 0 and 100.

    • l: number

      Some number between 0 and 100.

    • a: number

      Some number between 0 and 1.

    Returns Color

    A p5.js Color object matching the color specified by the given hsla values.

  • Parameters

    • h: number

      Some number between 0 and 360.

    • s: number

      Some number between 0 and 100.

    • l: number

      Some number between 0 and 100.

    • Optionala: number

      Some number between 0 and 1.

    Returns Color

    A p5.js Color object matching the color specified by the given hsla values.

  • The hex color string for the RGBA (red, green, blue, alpha) components of the color.

    Returns string

  • The hex color string for the RGBA (red, green, blue, alpha) components of the color.

    Parameters

    • withAlpha: boolean

      if true, an alpha component will be included in the hex string (#RRGGBBAA).
      If false, only the RGB components will be included (#RRGGBB).

    Returns string