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:
-
cStringThe color value.
Returns:
adjustSV
-
c -
s -
v
Adjusts the saturation and value of the color.
Parameters:
-
cStringThe color.
-
sStringThe saturation (0 - 100).
-
vStringThe value (0 - 100).
Returns:
analogic
-
c
Returns an array containing the two analogic colors.
Parameters:
-
cStringThe color value.
Returns:
b
-
c
Returns the blue component of a color value.
Parameters:
-
cStringThe color value
Returns:
complement
-
c
Returns a complementary color.
Parameters:
-
cStringThe color value.
Returns:
cutHex
-
c
Get a hexadecimal colour with the hash removed.
Parameters:
-
cStringThe color.
Returns:
cutRgb
-
c
Get an rgb colour as an array.
Parameters:
-
cStringThe color.
Returns:
darken
-
c -
p
Darkens a color by the given percentage.
Parameters:
-
cStringThe color.
-
pStringThe percentage as a fraction (0 - 1).
Returns:
desaturate
-
c -
p
desaturates a color by the given percentage.
Parameters:
-
cStringThe color.
-
pStringThe percentage as a fraction (0 - 1).
Returns:
g
-
c
Returns the green component of a color value.
Parameters:
-
cStringThe 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:
-
c1StringThe starting color.
-
c2StringThe target color.
-
fNumberA 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:
-
cStringThe color value.
Returns:
HSVtoRGB
-
c
Converts HSV to RGB.
Parameters:
-
cStringAn array of the form "[h, s, v, a]".
Returns:
hueShift
-
h -
amount
Shifts the hue by the given amount.
Parameters:
-
hNumberThe hue 0 - 360.
-
amountNumberThe amount 0 - 360.
intToHex
-
n
Get the hexadecimal value of an integer.
Parameters:
-
nNumberThe integer.
Returns:
isHex
-
c
Tests if the color is a hex.
Parameters:
-
cStringThe color.
Returns:
isHSV
-
c
Tests if the color is a hsv.
Parameters:
-
cStringThe color.
Returns:
isRGB
-
c
Tests if the color is a rgb.
Parameters:
-
cStringThe color.
Returns:
lighten
-
c -
p
Lightens a color by the given percentage.
Parameters:
-
cStringThe color.
-
pStringThe percentage as a fraction (0 - 1).
Returns:
r
-
c
Returns the red component of a color value.
Parameters:
-
cStringThe color value.
Returns:
rgba
-
r -
g -
b -
a
Returns a color value with the given red, green, blue, and alpha components.
Parameters:
-
rNumberThe red component (0-255).
-
gNumberThe green component (0-255).
-
bNumberThe blue component (0-255).
-
aNumberThe alpha component (0-1).
Returns:
s
-
c
Returns the saturation component of a color value.
Parameters:
-
cStringThe color value.
Returns:
saturate
-
c -
p
Saturates a color by the given percentage.
Parameters:
-
cStringThe color.
-
pStringThe 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:
-
cStringA 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:
-
cStringA string of the form "rgb(25,90,127)" or "#FFFFFF".
-
alphaNumberThe alpha value 0 to 1.
Returns:
toRGBA
-
c -
alpha
Returns a color value with the given red, green, blue, and alpha components.
Parameters:
-
cStringA string of the form "rgb(25,90,127)" or "#FFFFFF".
-
alphaNumberThe alpha value 0 to 1.
Returns:
triad
-
c
Returns an array containing the two triad colors.
Parameters:
-
cStringThe color value.
Returns:
v
-
c
Returns the value component of a color value.
Parameters:
-
cStringThe color value.
Returns:
validHex
-
value
Validates a hex color.
Parameters:
-
valueStringThe color.