v1.2.0.1-beta1
|
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) |
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()
.
string toArgbHex | ( | ) |
Returns color formatted in AARRGGBB
format.
string toArgbHexString | ( | ) |
Returns color formatted in #AARRGGBB
format.
Alias: argb()
, tpcolor()
toString()
method is extended with "argb" and "hex8a" format specifiers (both are analogous). number getSaturation | ( | ) |
Returns the saturation value of this color.
Alias: saturation()
Returns a new color with this color and color2
mixed by amount
.
amount
should be in range of 0-100.
Color tint | ( | number | amount | ) |
Returns a new color with this color tinted by amount
.
amount
should be in range of 0-100.
Color shade | ( | number | amount | ) |
Returns a new color with this color shaded by amount
.
amount
should be in range of 0-100.
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.
bool isDarkerThan | ( | Color | secondColor | ) |
The color with less brightness value is considered as Darker.
bool isLighterThan | ( | Color | secondColor | ) |
Return the opposite value of isDarkerThan().
bool isWarm | ( | ) |
Returns true if this color is considered "warm" (higher red value than blue).
bool isCool | ( | ) |
Returns true if this color is considered "cool" (higher blue value than red).
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.
bool isCoolerThan | ( | Color | secondColor | ) |
Return the opposite value of isWarmer().
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)
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)
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)
Returns a new Color which is complimentary to color
.
This is a static function. Use it like Color.complement("green")
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)
The color with less brightness value is considered as Darker.
This is a static function. Use it like Color.isDarker("white", "black")
Return the opposite value of isDarker().
This is a static function. Use it like Color.isLighter("white", "black")
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")
Return the opposite value of isWarmer().
This is a static function. Use it like Color.isCooler("red", "blue")