SUI.color

The SUI.color namespace contains a set of utility functions for working with color codes.

Colors can be defined in different was. Popular methods use HSV or RGB color values. The latter can be represented in different ways in CSS: '#0010FF', '#01F' or 'rgb(0,16,255)'. In this namespace you'll find a set of functions for conversions between HTML/CSS color codes, RGB and HSV color values.

Defined in: color.js


Method summary

Attr. Type Name / Description
public String

colToCol(c)

Convert an HTML or CSS color code to a standard HTML color code (standardize color code).

public Object

colToHsv(c)

Convert an HTML or CSS color code to an HSV color definition.

public Object

colToRgb(c)

Convert an HTML or CSS color code to RGB color fractions.

public String

hsvToCol(c)

Convert a HSV color definition to an HTML color code.

public Object

hsvToRgb(c)

Convert a HSV color definition RGB color fractions.

public String

rgbToCol(c)

Convert a RGB color fractions to an HTML color code.

public Object

rgbToHsv(c)

Convert a RGB color fractions to an HTML color code.

 


Methods

public String colToCol( String c)

Convert an HTML or CSS color code to a standard HTML color code (standardize color code).

Parameters:

Name Type Description
String c A HTML or CSS color code, the following formats are allowed: #FFF, #FFFFFF, rgb(255,255,255).

Returns:

String An HTML color code (#FFFFFF).

public Object colToHsv( String c)

Convert an HTML or CSS color code to an HSV color definition.

Parameters:

Name Type Description
String c A HTML or CSS color code to convert to an HSV color object, the following formats are allowed: #FFF, #FFFFFF and rgb(255,255,255).

Returns:

Object An HSV color object with the following members: h (hue: 0-360), s: (saturation: 0-1), v: (value: 0-1)

public Object colToRgb( String c)

Convert an HTML or CSS color code to RGB color fractions.

Parameters:

Name Type Description
String c A HTML or CSS color code to convert to a RGB color object, the following formats are allowed: #FFF, #FFFFFF and rgb(255,255,255).

Returns:

Object An RGB color object with the following members: r (red: 0-1), g (green: 0-1) and b (blue: 0-1).

public String hsvToCol( Object c)

Convert a HSV color definition to an HTML color code.

Parameters:

Name Type Description
Object c An HSV color object with the following members: h (hue: 0-360), s: (saturation: 0-1), v: (value: 0-1) to convert to an HTML color code.

Returns:

String An HTML color code (#FFFFFF)

public Object hsvToRgb( Object c)

Convert a HSV color definition RGB color fractions.

Parameters:

Name Type Description
Object c An HSV color object with the following members: h (hue: 0-360), s: (saturation: 0-1), v: (value: 0-1) to convert to an HSV color object.

Returns:

Object An object with the following members: r, g and b, each within a range of 0 to 1.

public String rgbToCol( Object c)

Convert a RGB color fractions to an HTML color code.

Parameters:

Name Type Description
Object c An RGB color object with the following members: r (red: 0-1), g (green: 0-1) and b (blue: 0-1) to convert to an HTML color code.

Returns:

String An HTML color code (#FFFFFF).

public Object rgbToHsv( Object c)

Convert a RGB color fractions to an HTML color code.

Parameters:

Name Type Description
Object c An RGB color object with the following members: r (red: 0-1), g (green: 0-1) and b (blue: 0-1) to convert to an HSV color object.

Returns:

Object An HSV color object with the following members: h (hue: 0-360), s: (saturation: 0-1), v: (value: 0-1)