Reference Source
public class | source

Colors

The Colors object is is a class containing reusable static methods

Static Method Summary

Static Public Methods
public static

colorFilter(sBackground: String, iBoundary: Integer, aValues: Array): Boolean

Used to filter random colour values and ensure high contrast against background

public static

Converts a HEX string to an RGB value

public static

Returns a darker version of a color

public static

getRandomColor(sBackground: String, iBoundary: Integer): Object

Returns a random color (D3 object)

public static

getRandomPalette(iLength: Integer): Array

Returns a random color palette

Static Public Methods

public static colorFilter(sBackground: String, iBoundary: Integer, aValues: Array): Boolean source

Used to filter random colour values and ensure high contrast against background

Params:

NameTypeAttributeDescription
sBackground String

the type of background light/dark to filter for contrast

iBoundary Integer

the brightness value to filter

aValues Array

array of RGB values

Return:

Boolean

specify whether the values pass or fail

public static convertHexToRgb(sColor: String): Object source

Converts a HEX string to an RGB value

Params:

NameTypeAttributeDescription
sColor String

the HEX colour

Return:

Object

RGB color object

public static getDarkerColor(oColor: Object): Object source

Returns a darker version of a color

Params:

NameTypeAttributeDescription
oColor Object

RGB object

Return:

Object

darker RGB object

public static getRandomColor(sBackground: String, iBoundary: Integer): Object source

Returns a random color (D3 object)

Params:

NameTypeAttributeDescription
sBackground String

the type of background light/dark to filter for contrast

iBoundary Integer

the brightness value to filter

Return:

Object

randomly generated RGB object

public static getRandomPalette(iLength: Integer): Array source

Returns a random color palette

Params:

NameTypeAttributeDescription
iLength Integer

the size of the palette

Return:

Array

list of randomly generated RGB objects