Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • new Color(red?: number, green?: number, blue?: number, alpha?: number): Color
  • Creates a new color.

    remarks

    Values can only go up to 1.

    Parameters

    • red: number = 0

      The red value of the color, from 0 to 1.

    • green: number = 0

      The green value of the color, from 0 to 1.

    • blue: number = 0

      The blue value of the color, from 0 to 1.

    • alpha: number = 1

      The alpha value of the color, from 0 to 1, default to 1.

    Returns Color

Properties

Private _alpha

_alpha: number = 1

Private _blue

_blue: number = 0

Private _green

_green: number = 0

Private _red

_red: number = 0

Static Readonly BLACK

BLACK: Color = ...

Static Readonly BLUE

BLUE: Color = ...

Static Readonly GREEN

GREEN: Color = ...

Static Readonly RED

RED: Color = ...

Static Readonly WHITE

WHITE: Color = ...

Static prefixed

prefixed: string | boolean

Accessors

alpha

  • get alpha(): number
  • set alpha(value: number): void
  • Get the alpha value.

    remarks

    Alpha is the opacity, 1 means full visible, 0 means transparent.

    Returns number

    • The value, can only be from 0 up to 1.
  • Set the alpha value, emit the 'alphaChange' and 'change' events for the color.

    remarks

    Alpha is the transparency.

    Parameters

    • value: number

      The value, can only be form 0 up to 1.

    Returns void

    • The value, can only be from 0 up to 1.

blue

  • get blue(): number
  • set blue(value: number): void
  • Get the blue value.

    Returns number

    • The value, can only be from 0 up to 1.
  • Set the blue value, emit the 'blueChange' and 'change' events for the color.

    Parameters

    • value: number

      The value, can only be form 0 up to 1.

    Returns void

    • The value, can only be from 0 up to 1.

green

  • get green(): number
  • set green(value: number): void
  • Get the green value.

    Returns number

    • The value, can only be from 0 up to 1.
  • Set the green value, emit the 'greenChange' and 'change' events for the color.

    Parameters

    • value: number

      The value, can only be form 0 up to 1.

    Returns void

    • The value, can only be from 0 up to 1.

red

  • get red(): number
  • set red(value: number): void
  • Get the red value.

    Returns number

    • The value, can only be from 0 up to 1.
  • Set the red value, emit the 'redChange' and 'change' events for the color.

    Parameters

    • value: number

      The value, can only be form 0 up to 1.

    Returns void

    • The value, can only be from 0 up to 1.

rgb

  • get rgb(): RGB
  • set rgb(value: RGB): void

rgba

  • get rgba(): RGBA
  • set rgba(value: RGBA): void

Methods

addListener

  • addListener(event: string | symbol, fn: ListenerFn, context?: any): Color

emit

eventNames

  • eventNames(): (string | symbol)[]
  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

invert

  • Inverts the color returning its negative forme.

    example

    Color.WHITE.invert() === Color.BLACK;

    Returns Color

    • The resulting color.

listenerCount

  • listenerCount(event: string | symbol): number
  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

listeners

  • Return the listeners registered for a given event.

    Parameters

    • event: string | symbol

    Returns ListenerFn[]

off

  • off(event: string | symbol, fn?: ListenerFn, context?: any, once?: boolean): Color
  • Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns Color

on

  • on<K>(event: K, fn: (...params: ColorEvents[K]) => void, context?: any): Color

once

  • once<K>(event: K, fn: (...params: ColorEvents[K]) => void, context?: any): Color

removeAllListeners

  • removeAllListeners(event?: string | symbol): Color
  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: string | symbol

    Returns Color

removeListener

  • removeListener(event: string | symbol, fn?: ListenerFn, context?: any, once?: boolean): Color
  • Remove the listeners of a given event.

    Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns Color

set

  • set(red?: number, green?: number, blue?: number, alpha?: number): void
  • Sets the values of the color.

    Parameters

    • Optional red: number

      The red value.

    • Optional green: number

      The green value.

    • Optional blue: number

      The blue value.

    • Optional alpha: number

      The alpha value.

    Returns void

toHex

  • toHex(): number
  • Transforms the color to its hexadecimal form.

    example

    Color.RED.toHex() === 0xff0000

    Returns number

    • The resulting hexadecimal number.

toHexString

  • toHexString(): string
  • Transforms the color to its stringed hexadecimal form.

    example

    Color.BLUE.toHexString() === "#0000ff"

    Returns string

    • The resulting stringed hexadecimal form.

Static fromHex

  • fromHex(hex: number, alpha?: number): Color
  • Creates a color from a hexadecimal form.

    example

    Color.fromHex(0x000000) === Color.BLACK

    Parameters

    • hex: number

      The hexadecimal form of your color.

    • Optional alpha: number

      The alpha value of the color, defaults to 1.

    Returns Color

    • The resulting color.

Static fromHexString

  • fromHexString(hexString: string | `#${string}`, alpha?: number): Color
  • Creates a color from a stringed hexadecimal form.

    example

    Color.fromHexString("#00ff00") === Color.GREEN

    Parameters

    • hexString: string | `#${string}`

      The stringed hexadecimal form of your color.

    • Optional alpha: number

      The alpha value of the color, defaults to 1.

    Returns Color

    • The resulting color.

Static invert

  • Inverts a color returning its negative forme.

    example

    Color.invert(Color.WHITE) === Color.BLACK;

    Parameters

    • color: Color

      The color to invert.

    Returns Color

    • The resulting color.

Static random

Static toHex

  • toHex(color: Color): number
  • Transforms a color to its hexadecimal form.

    example

    Color.toHex(Color.RED) === 0xff0000

    Parameters

    • color: Color

      The color to get its hexadecimal form.

    Returns number

    • The resulting hexadecimal number.

Static toHexString

  • toHexString(color: Color): `#${string}`
  • Transforms a color to its stringed hexadecimal form.

    example

    Color.toHex(Color.BLUE) === "#0000ff"

    Parameters

    • color: Color

      The color to get its stringed hexadecimal form.

    Returns `#${string}`

    • The resulting stringed hexadecimal form.

Generated using TypeDoc