Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Color

A convenience class for working with and manipulating colors.

export

Hierarchy

  • Color

Index

Constructors

constructor

  • new Color(value: any): Color
  • Parameters

    • value: any

    Returns Color

Accessors

alpha

  • get alpha(): number
  • set alpha(value: number): void
  • Returns the color's alpha value in the set [0, 1].

    memberof

    Color

    Returns number

  • Sets the color's alpha value, which must be in the set [0, 1].

    memberof

    Color

    Parameters

    • value: number

    Returns void

blue

  • get blue(): number
  • set blue(value: number): void
  • Returns the color's blue value in the set [0, 255].

    memberof

    Color

    Returns number

  • Sets the color's blue value, which must be in the set [0, 255].

    memberof

    Color

    Parameters

    • value: number

    Returns void

green

  • get green(): number
  • set green(value: number): void
  • Returns the color's green value in the set [0, 255].

    memberof

    Color

    Returns number

  • Sets the color's green value, which must be in the set [0, 255].

    memberof

    Color

    Parameters

    • value: number

    Returns void

red

  • get red(): number
  • set red(value: number): void
  • Returns the color's red value in the set [0, 255].

    memberof

    Color

    Returns number

  • Sets the color's red value, which must be in the set [0, 255].

    memberof

    Color

    Parameters

    • value: number

    Returns void

Methods

brighten

  • brighten(percent?: number): void
  • Brightens the color by a specified percentage.

    memberof

    Color

    Parameters

    • Default value percent: number = 10

    Returns void

brightness

  • brightness(): number
  • Returns the brightness of the color.

    memberof

    Color

    Returns number

darken

  • darken(percent?: number): { a?: number; b: number; g: number; r: number }
  • Darkens the color by a specified percentage.

    memberof

    Color

    Parameters

    • Default value percent: number = 10

    Returns { a?: number; b: number; g: number; r: number }

    • Optional a?: number
    • b: number
    • g: number
    • r: number

isDark

  • isDark(): boolean
  • Returns whether the color is dark based on its luminance.

    memberof

    Color

    Returns boolean

isLight

  • isLight(): boolean
  • Returns whether the color is light based on its luminance.

    memberof

    Color

    Returns boolean

lighten

  • lighten(percent?: number): { a?: number; b: number; g: number; r: number }
  • Increases the lightness of the color by a specified percentage.

    memberof

    Color

    Parameters

    • Default value percent: number = 10

    Returns { a?: number; b: number; g: number; r: number }

    • Optional a?: number
    • b: number
    • g: number
    • r: number

luminance

  • luminance(): number
  • Returns the luminance of the color.

    memberof

    Color

    Returns number

toHex

  • toHex(): string
  • Returns the hex value for the color.

    memberof

    Color

    Returns string

toHsl

  • Returns the HSL (hue, saturation, lightness) for the color.

    memberof

    Color

    Returns HSL

toHsv

  • Returns the HSV (hue, saturation, value) for the color.

    memberof

    Color

    Returns HSV

toString

  • toString(format?: string): string
  • Returns a string representation of the color in the specified format.

    memberof

    Color

    Parameters

    • Optional format: string

    Returns string

Generated using TypeDoc