Options
All
  • Public
  • Public/Protected
  • All
Menu

Color object is represents rbg color with alpha chanell

Note: there is nothing as fromObject and toObject because much better and most logic way how top serialize color is to serialize it to hex string #009edd

collboard-modules-sdk

Hierarchy

  • Color

Index

Constructors

  • Returns Color

Properties

alpha: number
blue: number
green: number
red: number
fromHex3: any

Creates a new Color instance from color in hex format with 3 color digits

param color

in hex for example 09d

returns

Color object

fromHex6: any

Creates a new Color instance from color in hex format with 6 color digits

param color

in hex for example 009edd

returns

Color object

Accessors

  • Returns Color

  • Returns Color

  • Returns Color

  • Returns Color

Methods

  • addLightness(delta: number): Color
  • Parameters

    • delta: number

    Returns Color

  • Returns Color

  • Creates best text color for this background color

    Returns Color

    white or black color

  • toHex(): string
  • Returns string

  • toHsl(): string
  • Returns string

  • toString(): string
  • Returns string

  • withAlpha(alpha: number): Color
  • Parameters

    • alpha: number

    Returns Color

  • withMutation(modifier: (red: number, green: number, blue: number, opacity: number) => [number, number, number, number]): Color
  • Parameters

    • modifier: (red: number, green: number, blue: number, opacity: number) => [number, number, number, number]
        • (red: number, green: number, blue: number, opacity: number): [number, number, number, number]
        • Parameters

          • red: number
          • green: number
          • blue: number
          • opacity: number

          Returns [number, number, number, number]

    Returns Color

  • Creates a new Color instance from miscellaneous formats

    • It can receive Color instance and just return the same instance
    • It can receive color in string format for example #009edd, rgb(0,158,221), rgb(0%,62%,86.7%), hsl(197.1,100%,43.3%)

    Note: This is not including fromImage because detecting color from an image is heavy task which requires async stuff and we cannot safely determine with overloading if return value will be a promise

    Parameters

    Returns Color

    Color object

  • fromHex(hex: string): Color
  • Creates a new Color instance from color in hex format

    Parameters

    • hex: string

    Returns Color

    Color object

  • fromHsl(hsl: string): Color
  • Creates a new Color instance from color in hsl format

    Parameters

    • hsl: string

    Returns Color

    Color object

  • fromImage(image: string): Promise<Color>
  • Creates a new Color instance from average color of given image

    Parameters

    • image: string

      as a source for example data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjYJh39z8ABJgCe/ZvAS4AAAAASUVORK5CYII=

    Returns Promise<Color>

    Color object

  • fromRgbString(rgb: string): Color
  • Creates a new Color instance from color in rgb format

    Parameters

    • rgb: string

    Returns Color

    Color object

  • fromRgbaString(rgba: string): Color
  • Creates a new Color instance from color in rbga format

    Parameters

    • rgba: string

    Returns Color

    Color object

  • fromString(color: string): Color
  • Creates a new Color instance from miscellaneous string formats

    Parameters

    • color: string

      as a string for example #009edd, rgb(0,158,221), rgb(0%,62%,86.7%), hsl(197.1,100%,43.3%), red, darkgrey,...

    Returns Color

    Color object