v1.2.0.1-beta1

Description

Provides functions for working with color.

New instances can be created with new Color(input) or just Color(input). Static functions are invoked with Color. qualifier.

Library originally from TinyColor. This object can also be invoked with tinycolor().

The library has been extended with extra functions described below. For the rest of the documentation, with examples, please see original reference at https://github.com/bgrins/TinyColor#usage
There is also a basic demo page with some more details at http://bgrins.github.io/TinyColor/

The following methods are aliases of their longer counterparts (unlinked ones are documented at TinyColor site):

  • originalInput() = getOriginalInput();
  • format() = getFormat();
  • alpha() = getAlpha();
  • brightness() = getBrightness();
  • luminance() = getLuminance();
  • saturation() = getSaturation();
  • hsv() = toHsvString();
  • hsl() = toHslString();
  • hex() = toHexString();
  • rgba() = toHex8String();
  • argb() = toArgbHexString();
  • rgb() = toRgbString();
  • prgb() = toPercentageRgbString();

In addition, the toString() method is extended with "argb" and "hex8a" format specifiers (both are analogous), see toArgbHexString().

Public Member Functions

string tpcolor ()
 
string toArgbHex ()
 
string toArgbHexString ()
 
number getSaturation ()
 
Color mixWith (Color color2, number amount)
 
Color tint (number amount)
 
Color shade (number amount)
 
Color polyad (number n)
 
bool isDarkerThan (Color secondColor)
 
bool isLighterThan (Color secondColor)
 
bool isWarm ()
 
bool isCool ()
 
bool isWarmerThan (Color secondColor)
 
bool isCoolerThan (Color secondColor)
 

Static Public Member Functions

Color mix (Color color1, Color color2, number amount)
 
Color tint (Color color, number amount)
 
Color shade (Color color, number amount)
 
Color complement (Color color)
 
Color polyad (Color color, number n)
 
bool isDarker (Color color1, Color color2)
 
bool isLighter (Color color1, Color color2)
 
bool isWarmer (Color color1, Color color2)
 
bool isCooler (Color color1, Color color2)
 

Member Function Documentation

◆ tpcolor()

string tpcolor ( )

Returns color formatted in #AARRGGBB format (this is suitable for use with Touch Portal's "Set Text/Background color from plug-in state" action).


Same as argb() and toArgbHexString().

◆ toArgbHex()

string toArgbHex ( )

Returns color formatted in AARRGGBB format.

◆ toArgbHexString()

string toArgbHexString ( )

Returns color formatted in #AARRGGBB format.

Alias: argb(), tpcolor()

In addition, the toString() method is extended with "argb" and "hex8a" format specifiers (both are analogous).

◆ getSaturation()

number getSaturation ( )

Returns the saturation value of this color.

Alias: saturation()

◆ mixWith()

Color mixWith ( Color  color2,
number  amount 
)

Returns a new color with this color and color2 mixed by amount.

amount should be in range of 0-100.

◆ tint() [1/2]

Color tint ( number  amount)

Returns a new color with this color tinted by amount.

amount should be in range of 0-100.

◆ shade() [1/2]

Color shade ( number  amount)

Returns a new color with this color shaded by amount.

amount should be in range of 0-100.

◆ polyad() [1/2]

Color polyad ( number  n)

Returns an array of up to n colors harmonious with this color.

Same as triad() and tetrad() when called with values 3 and 4, respectively.

◆ isDarkerThan()

bool isDarkerThan ( Color  secondColor)

The color with less brightness value is considered as Darker.

◆ isLighterThan()

bool isLighterThan ( Color  secondColor)

Return the opposite value of isDarkerThan().

◆ isWarm()

bool isWarm ( )

Returns true if this color is considered "warm" (higher red value than blue).

◆ isCool()

bool isCool ( )

Returns true if this color is considered "cool" (higher blue value than red).

◆ isWarmerThan()

bool isWarmerThan ( Color  secondColor)

Returns true if the color is warmer i.e.

have more red value. If both colors have the same red value the one with less green and blue values is considered warmer.

◆ isCoolerThan()

bool isCoolerThan ( Color  secondColor)

Return the opposite value of isWarmer().

◆ mix()

Color mix ( Color  color1,
Color  color2,
number  amount 
)
static

Returns a new color with color1 and color2 mixed by amount.

amount should be in range of 0-100.

This is a static function. Use it like Color.mix("red", "blue", 50)

◆ tint() [2/2]

Color tint ( Color  color,
number  amount 
)
static

Returns a new Color of color by amount.

amount should be in range of 0-100.

This is a static function. Use it like Color.tint("red", 50)

◆ shade() [2/2]

Color shade ( Color  color,
number  amount 
)
static

Returns a new Color with color shaded by amount.

amount should be in range of 0-100.

This is a static function. Use it like Color.shade("red", 50)

◆ complement()

Color complement ( Color  color)
static

Returns a new Color which is complimentary to color.

This is a static function. Use it like Color.complement("green")

◆ polyad() [2/2]

Color polyad ( Color  color,
number  n 
)
static

Returns an array of up to n colors harmonious to color.

Same as triad(color) and tetrad(color) when called with values 3 and 4, respectively.

This is a static function. Use it like Color.polyad("green", 3)

◆ isDarker()

bool isDarker ( Color  color1,
Color  color2 
)
static

The color with less brightness value is considered as Darker.

This is a static function. Use it like Color.isDarker("white", "black")

◆ isLighter()

bool isLighter ( Color  color1,
Color  color2 
)
static

Return the opposite value of isDarker().

This is a static function. Use it like Color.isLighter("white", "black")

◆ isWarmer()

bool isWarmer ( Color  color1,
Color  color2 
)
static

Returns true if the color is warmer i.e, has more red value.

If both colors have the same red value the one with less green and blue values is considered warmer.
This is a static function. Use it like Color.isWarmer("red", "blue")

◆ isCooler()

bool isCooler ( Color  color1,
Color  color2 
)
static

Return the opposite value of isWarmer().

This is a static function. Use it like Color.isCooler("red", "blue")