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

Constructors

  • Parameters

    Returns Color

  • Parameters

    • red: number
    • green: number
    • blue: number
    • Optionalalpha: number

    Returns Color

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.

    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.

    Parameters

    • c: Color

      A p5.js Color object. The color's RGBA components will become the new values of red, green, blue, and alpha.

    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.

    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.

    Parameters

    • r: number

    Returns void

Methods

  • Copy the given Color object and return a new, distinct object.

    Parameters

    Returns Color

  • 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