Show:

ia.Color Class

Defined in: ia\utils\Color.js:1
Module: ia

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

()

Defined in ia\utils\Color.js:1

Item Index

Methods

Methods

a

(
  • c
)
String static

Returns the alpha component of a color value.

Parameters:

  • c String

    The color value.

Returns:

String: The alpha component.

adjustSV

(
  • c
  • s
  • v
)
String static

Adjusts the saturation and value of the color.

Parameters:

  • c String

    The color.

  • s String

    The saturation (0 - 100).

  • v String

    The value (0 - 100).

Returns:

String: The new color as a hex value.

analogic

(
  • c
)
static

Returns an array containing the two analogic colors.

Parameters:

  • c String

    The color value.

Returns:

[String] The two analogic colors.

b

(
  • c
)
String static

Returns the blue component of a color value.

Parameters:

  • c String

    The color value

Returns:

String: The blue component

complement

(
  • c
)
String static

Returns a complementary color.

Parameters:

  • c String

    The color value.

Returns:

String: The complemetary color value.

cutHex

(
  • c
)
String static

Get a hexadecimal colour with the hash removed.

Parameters:

  • c String

    The color.

Returns:

String: The color.

cutRgb

(
  • c
)
Array static

Get an rgb colour as an array.

Parameters:

  • c String

    The color.

Returns:

Array: An array.

darken

(
  • c
  • p
)
String static

Darkens a color by the given percentage.

Parameters:

  • c String

    The color.

  • p String

    The percentage as a fraction (0 - 1).

Returns:

String: The new color as a hex value.

desaturate

(
  • c
  • p
)
String static

desaturates a color by the given percentage.

Parameters:

  • c String

    The color.

  • p String

    The percentage as a fraction (0 - 1).

Returns:

String: The new color as a hex value.

g

(
  • c
)
String static

Returns the green component of a color value.

Parameters:

  • c String

    The color value.

Returns:

String: The green component.

getInterpolatedColor

(
  • c1
  • c2
  • f
)
String static

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 String

    The starting color.

  • c2 String

    The target color.

  • f Number

    A fraction between 0 and 1 controlling the interpolation.

Returns:

String: The interpolated color.

getRandomColor

() String static

Returns a randomly generated color.

Returns:

String: The random color.

h

(
  • c
)
String static

Returns the hue component of a color value.

Parameters:

  • c String

    The color value.

Returns:

String: The hue component 0 - 360.

HSVtoRGB

(
  • c
)
String static

Converts HSV to RGB.

Parameters:

  • c String

    An array of the form "[h, s, v, a]".

Returns:

String: A string of the form "rgb(25,90,127, 0.1)".

hueShift

(
  • h
  • amount
)
static

Shifts the hue by the given amount.

Parameters:

  • h Number

    The hue 0 - 360.

  • amount Number

    The amount 0 - 360.

intToHex

(
  • n
)
String static

Get the hexadecimal value of an integer.

Parameters:

  • n Number

    The integer.

Returns:

String: The hexadecimal value.

isHex

(
  • c
)
Boolean static

Tests if the color is a hex.

Parameters:

  • c String

    The color.

Returns:

Boolean: true or false.

isHSV

(
  • c
)
Boolean static

Tests if the color is a hsv.

Parameters:

  • c String

    The color.

Returns:

Boolean: true or false.

isRGB

(
  • c
)
Boolean static

Tests if the color is a rgb.

Parameters:

  • c String

    The color.

Returns:

Boolean: true or false.

lighten

(
  • c
  • p
)
String static

Lightens a color by the given percentage.

Parameters:

  • c String

    The color.

  • p String

    The percentage as a fraction (0 - 1).

Returns:

String: The new color as a hex value.

r

(
  • c
)
String static

Returns the red component of a color value.

Parameters:

  • c String

    The color value.

Returns:

String: The red component.

rgba

(
  • r
  • g
  • b
  • a
)
String static

Returns a color value with the given red, green, blue, and alpha components.

Parameters:

  • r Number

    The red component (0-255).

  • g Number

    The green component (0-255).

  • b Number

    The blue component (0-255).

  • a Number

    The alpha component (0-1).

Returns:

String: The color value.

s

(
  • c
)
String static

Returns the saturation component of a color value.

Parameters:

  • c String

    The color value.

Returns:

String: The hue component 0 - 100.

saturate

(
  • c
  • p
)
String static

Saturates a color by the given percentage.

Parameters:

  • c String

    The color.

  • p String

    The percentage as a fraction (0 - 1).

Returns:

String: The new color as a hex value.

toHex

(
  • c
)
String static

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 String

    A string of the form "rgb(25,90,127)" or "#FFFFFF".

Returns:

String: The hex color value or 0.

toHSVA

(
  • c
  • alpha
)
String static

Returns a color value with the given hue, saturation, value, and alpha components.

Parameters:

  • c String

    A string of the form "rgb(25,90,127)" or "#FFFFFF".

  • alpha Number

    The alpha value 0 to 1.

Returns:

String: An of the form "[255,100,100,1]" - "[h,s,v,a]".

toRGBA

(
  • c
  • alpha
)
String static

Returns a color value with the given red, green, blue, and alpha components.

Parameters:

  • c String

    A string of the form "rgb(25,90,127)" or "#FFFFFF".

  • alpha Number

    The alpha value 0 to 1.

Returns:

String: A string of the form "rgb(25,90,127, 0.1)".

triad

(
  • c
)
static

Returns an array containing the two triad colors.

Parameters:

  • c String

    The color value.

Returns:

[String] The two triad colors.

v

(
  • c
)
String static

Returns the value component of a color value.

Parameters:

  • c String

    The color value.

Returns:

String: The hue component 0 - 100.

validHex

(
  • value
)
String static

Validates a hex color.

Parameters:

  • value String

    The color.

Returns:

String: The validated value.