stack

Home > @infiniteobjects/data-types > Color

Color class

Color manager, Expressed in RGBA

Signature:

export declare class Color implements RGBA 

Implements: RGBA

Remarks

Defaults to black

Constructors

Constructor Modifiers Description
(constructor)(r, g, b, a)   Creates a new color instance

Properties

Property Modifiers Type Description
a   unit Alpha Component
b   bit8 Blue Component
g   bit8 Green Component
r   bit8 Red Component

Methods

Method Modifiers Description
brighten(amount)   Brighten the color a given amount.
clone()   Clones the current Color (new instane)
complement()   Gets the complement of the current color (new Instance)
darken(amount)   Darken the color a given amount. Providing 100 will always return black.
desaturate(amount)   Desaturate the color a given amount. Providing 100 will is the same as calling greyscale.
fromString(color) static Creates a new color from the given string
greyscale()   Completely desaturate a color into greyscale. Same as calling desaturate(100).
isDark()   Return an indication whether the color’s perceived brightness is dark.
isLight()   Return an indication whether the color’s perceived brightness is light.
isValid()   Return a boolean indicating whether the color was successfully parsed.
isValid(color) static Return a boolean indicating whether the color was successfully parsed.
lighten(amount)   Lighten the color a given amount. Providing 100 will always return white.
mix(color1, color2, amount) static Mixes 2 colors
saturate(amount)   Saturate the color a given amount.
spin(amount)   Spin the hue a given amount. Calling with 0, 360, or -360 will do nothing.
toHex()   Returns the hex value of the color.
toHex8()   Returns the hex 8 value of the color.
toHex8String()   Returns the hex 8 value of the color -with a # append.
toHexString()   Returns the hex value of the color -with a # append.
toHsl()   Returns the object as a HSLA object.
toHslString()   Returns the hsla values interpolated into a string with the following format: “hsla(xxx, xxx, xxx, xx)”.
toHsv()   Returns the object as a HSVA object.
toHsvString()   Returns the hsva values interpolated into a string with the following format: “hsva(xxx, xxx, xxx, xx)”.
toJSON()   Serialized version
toRgb()   Returns the object as a RGBA object.
toRgbString()   Returns the RGBA values interpolated into a string with the following format: “RGBA(xxx, xxx, xxx, xx)”.