This class contains methods that can be helpful when working with color (in particular color models: RGB, HSV, etc.).
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.
Convert RGB hex string to list of rgb values.
List hexToRGB(String hexRGB)
hexRGB - RGB hex value prepended with "#"
List - The hexRGB string returned as a list of Integer values.
log.debug hubitat.helper.ColorUtils.hexToRGB("#7EFF00") == [126,255,0]
Convert RGB list value to hex string.
String rgbToHEX(List RGB)
RGB - Red, Green, Blue (valid values are 0..255)
String - The RGB value of the integer list encoded as a hex string.
log.debug hubitat.helper.ColorUtils.rgbToHEX([126,255,0]) == "#7EFF00"
Convert RGB list values to Hue, Saturation and Level list
List rgbToHSV(List RGB)
List - the rgb list to convert
List - Hue, Saturation and Level
log.debug hubitat.helper.ColorUtils.rgbToHSV([126,255,0])
// == [25.1, 100.0, 100.0]
Convert Hue, Saturation and Level list to rgb list
List hsvToRGB(List HSV)
List - the hsv list to convert. (valid values are 0..100)
List - The HSV List returned as a list of rgb Integer values.
log.debug hubitat.helper.ColorUtils.hsvToRGB([25.1, 100.0, 100.0]) == [126, 255, 0]
Convert HSV values (hue, saturation, and brightness each from 0 to 100) to CIE xy chromaticity and brightness. Note: this method scales the first three values of the list you pass in, in place.
List hsvToXY(List hsv)hsv - Mutable list of hue, saturation, and brightness values from 0 through 100; this method scales its first three values in place during conversionA list containing the x and y chromaticity (rounded to four decimal places) followed by the brightness; empty if the list does not contain three values
Convert HSV values using a 0-to-360 hue scale to RGB channels.
List hsv360ToRGB(List hsv)hsv - List of hue in degrees and saturation/value percentagesList of red, green, and blue channel integers; empty when the list does not contain three values
Convert HSV values with a 0 to 360 hue scale (hue in degrees; saturation and brightness percentages) to CIE xy chromaticity and brightness. Note: this method scales the first three values of the list you pass in, in place.
List hsv360ToXY(List hsv)hsv - Mutable list of hue in degrees and saturation/brightness percentages; this method scales its first three values in place during conversionA list containing the x and y chromaticity (rounded to four decimal places) followed by the brightness; empty if the list does not contain three values
Convert RGB channels to HSV with hue scaled from 0 to 360.
List rgbToHSV360(List rgb)rgb - List of exactly three red, green, blue channel values from 0 through 255List of hue in degrees, saturation percent, and value percent, rounded to two decimal places; empty when the list does not contain three values
Convert RGB channels to CIE xy chromaticity and brightness.
List rgbToXY(List rgb)rgb - List of exactly three red, green, blue channel values from 0 through 255List containing x and y chromaticity rounded to four decimal places, followed by brightness from 0 through 100; empty when the list does not contain three values