ia.Color Class
The Color
class is an all-static class with methods for working with colors.
You do not create instances of Color
instead you simply call static methods
such as the Color.getRandomColor()
method.
All colors must use the format #RRGGBB. RR, GG, and BB each consist of two hexadecimal digits that specify the offset of each color component.
Constructor
ia.Color
()
Item Index
Methods
- a static
- adjustSV static
- analogic static
- b static
- complement static
- cutHex static
- cutRgb static
- darken static
- desaturate static
- g static
- getInterpolatedColor static
- getRandomColor static
- h static
- HSVtoRGB static
- hueShift static
- intToHex static
- isHex static
- isHSV static
- isRGB static
- lighten static
- r static
- rgba static
- s static
- saturate static
- toHex static
- toHSVA static
- toRGBA static
- triad static
- v static
- validHex static
Methods
a
-
c
Returns the alpha component of a color value.
Parameters:
-
c
StringThe color value.
Returns:
adjustSV
-
c
-
s
-
v
Adjusts the saturation and value of the color.
Parameters:
-
c
StringThe color.
-
s
StringThe saturation (0 - 100).
-
v
StringThe value (0 - 100).
Returns:
analogic
-
c
Returns an array containing the two analogic colors.
Parameters:
-
c
StringThe color value.
Returns:
b
-
c
Returns the blue component of a color value.
Parameters:
-
c
StringThe color value
Returns:
complement
-
c
Returns a complementary color.
Parameters:
-
c
StringThe color value.
Returns:
cutHex
-
c
Get a hexadecimal colour with the hash removed.
Parameters:
-
c
StringThe color.
Returns:
cutRgb
-
c
Get an rgb colour as an array.
Parameters:
-
c
StringThe color.
Returns:
darken
-
c
-
p
Darkens a color by the given percentage.
Parameters:
-
c
StringThe color.
-
p
StringThe percentage as a fraction (0 - 1).
Returns:
desaturate
-
c
-
p
desaturates a color by the given percentage.
Parameters:
-
c
StringThe color.
-
p
StringThe percentage as a fraction (0 - 1).
Returns:
g
-
c
Returns the green component of a color value.
Parameters:
-
c
StringThe color value.
Returns:
getInterpolatedColor
-
c1
-
c2
-
f
Interpolate between two color values by the given mixing proportion. A mixing fraction of 0 will result in c1, a value of 1.0 will result in c2, and value of 0.5 will result in the color mid-way between the two in RGB color space.
Parameters:
-
c1
StringThe starting color.
-
c2
StringThe target color.
-
f
NumberA fraction between 0 and 1 controlling the interpolation.
Returns:
getRandomColor
()
String
static
Returns a randomly generated color.
Returns:
h
-
c
Returns the hue component of a color value.
Parameters:
-
c
StringThe color value.
Returns:
HSVtoRGB
-
c
Converts HSV to RGB.
Parameters:
-
c
StringAn array of the form "[h, s, v, a]".
Returns:
hueShift
-
h
-
amount
Shifts the hue by the given amount.
Parameters:
-
h
NumberThe hue 0 - 360.
-
amount
NumberThe amount 0 - 360.
intToHex
-
n
Get the hexadecimal value of an integer.
Parameters:
-
n
NumberThe integer.
Returns:
isHex
-
c
Tests if the color is a hex.
Parameters:
-
c
StringThe color.
Returns:
isHSV
-
c
Tests if the color is a hsv.
Parameters:
-
c
StringThe color.
Returns:
isRGB
-
c
Tests if the color is a rgb.
Parameters:
-
c
StringThe color.
Returns:
lighten
-
c
-
p
Lightens a color by the given percentage.
Parameters:
-
c
StringThe color.
-
p
StringThe percentage as a fraction (0 - 1).
Returns:
r
-
c
Returns the red component of a color value.
Parameters:
-
c
StringThe color value.
Returns:
rgba
-
r
-
g
-
b
-
a
Returns a color value with the given red, green, blue, and alpha components.
Parameters:
-
r
NumberThe red component (0-255).
-
g
NumberThe green component (0-255).
-
b
NumberThe blue component (0-255).
-
a
NumberThe alpha component (0-1).
Returns:
s
-
c
Returns the saturation component of a color value.
Parameters:
-
c
StringThe color value.
Returns:
saturate
-
c
-
p
Saturates a color by the given percentage.
Parameters:
-
c
StringThe color.
-
p
StringThe percentage as a fraction (0 - 1).
Returns:
toHex
-
c
Returns a color value for a given string. Checks if the color is hex. If it is hex the hex value is simply returned. If its is rgb it is converted into hex and returned
Parameters:
-
c
StringA string of the form "rgb(25,90,127)" or "#FFFFFF".
Returns:
toHSVA
-
c
-
alpha
Returns a color value with the given hue, saturation, value, and alpha components.
Parameters:
-
c
StringA string of the form "rgb(25,90,127)" or "#FFFFFF".
-
alpha
NumberThe alpha value 0 to 1.
Returns:
toRGBA
-
c
-
alpha
Returns a color value with the given red, green, blue, and alpha components.
Parameters:
-
c
StringA string of the form "rgb(25,90,127)" or "#FFFFFF".
-
alpha
NumberThe alpha value 0 to 1.
Returns:
triad
-
c
Returns an array containing the two triad colors.
Parameters:
-
c
StringThe color value.
Returns:
v
-
c
Returns the value component of a color value.
Parameters:
-
c
StringThe color value.
Returns:
validHex
-
value
Validates a hex color.
Parameters:
-
value
StringThe color.