ColorUtils Object

From Hubitat Documentation
Revision as of 18:47, 1 August 2019 by Mike.maxwell (talk | contribs)
Jump to: navigation, search

Description

The package name of this class is hubitat.helper. So to use in an App or Driver you would reference it with hubitat.helper.ColorUtils.

hexToRGB

Convert RGB hex string to list of rgb values.

Signature

List hexToRGB(String hexRGB)

Parameters

hexRGB - RGB hex value prepended with "#"

Returns

List - The hexRGB string returned as a list of Integer values.

Example

log.debug hubitat.helper.ColorUtils.hexToRGB("#7EFF00") == [126,255,0]


rgbToHEX

Convert RGB list value to hex string.

Signature

String rgbToHEX(List RGB)

Parameters

RGB - Red, Green, Blue (valid values are 0..255)

Returns

String - The RGB value of the integer list encoded as a hex string.

Example

log.debug hubitat.helper.ColorUtils.rgbToHEX([126,255,0]) == "#7EFF00"

rgbToHSV

Convert RGB list values to Hue, Saturation and Level list

Signature

List rgbToHSV(List RGB)

Parameters

List - the rgb list to convert

Returns

List - Hue, Saturation and Level 

Example

log.debug hubitat.helper.ColorUtils.rgbToHSV([126,255,0]) == [25.1, 100.0, 100.0]


hsvToRGB

Convert Hue, Saturation and Level list to rgb list

Signature

String hsvToRGB(List HSV)

Parameters

List - the hsv list to convert. (valid values are 0..100)

Returns

List - The HSV List returned as a list of rgb Integer values.

Example

log.debug hubitat.helper.ColorUtils.hsvToRGB([25.1, 100.0, 100.0]) == [126, 255, 0]