Class: Caman.Convert
Defined in: | src/core/convert.coffee |
Overview
Tons of color conversion utility functions.
Class Method Summary
- + (Array) hexToRGB(hex) Converts the hex representation of a color to RGB values.
- + (Array) rgbToHSL(r, g, b) Converts an RGB color to HSL.
- + (Array) hslToRGB(h, s, l) Converts an HSL color value to RGB.
- + (Number) hueToRGB(p, q, t) Converts from the hue color space back to RGB.
- + (Array) rgbToHSV(r, g, b) Converts an RGB color value to HSV.
- + (Array) hsvToRGB(h, s, v) Converts an HSV color value to RGB.
- + (Array) rgbToXYZ(r, g, b) Converts a RGB color value to the XYZ color space.
- + (Array) xyzToRGB(x, y, z) Converts a XYZ color value to the sRGB color space.
- + (Array) xyzToLab(x, y, z) Converts a XYZ color value to the CIELAB color space.
- + (Array) labToXYZ(l, a, b) Converts a L, a, b* color values from the CIELAB color space to the XYZ color space.
- + (void) rgbToLab(r, g, b) Converts L, a, b* back to RGB values.
- + (void) labToRGB(l, a, b)
Class Method Details
+ (Array) hexToRGB(hex)
Converts the hex representation of a color to RGB values. Hex value can optionally start with the hash (#).
+ (Array) rgbToHSL(r, g, b)
+ (Array) rgbToHSL(rgb)
Converts an RGB color to HSL. Assumes r, g, and b are in the set [0, 255] and returns h, s, and l in the set [0, 1].
+ (Array) hslToRGB(h, s, l)
+ (Array) hslToRGB(hsl)
Converts an HSL color value to RGB. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes h, s, and l are contained in the set [0, 1] and returns r, g, and b in the set [0, 255].
+ (Number) hueToRGB(p, q, t)
Converts from the hue color space back to RGB.
+ (Array) rgbToHSV(r, g, b)
Converts an RGB color value to HSV. Conversion formula adapted from {http://en.wikipedia.org/wiki/HSV_color_space}. Assumes r, g, and b are contained in the set [0, 255] and returns h, s, and v in the set [0, 1].
+ (Array) hsvToRGB(h, s, v)
Converts an HSV color value to RGB. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes h, s, and v are contained in the set [0, 1] and returns r, g, and b in the set [0, 255].
+ (Array) rgbToXYZ(r, g, b)
Converts a RGB color value to the XYZ color space. Formulas are based on http://en.wikipedia.org/wiki/SRGB assuming that RGB values are sRGB.
Assumes r, g, and b are contained in the set [0, 255] and returns x, y, and z.
+ (Array) xyzToRGB(x, y, z)
Converts a XYZ color value to the sRGB color space. Formulas are based on http://en.wikipedia.org/wiki/SRGB and the resulting RGB value will be in the sRGB color space. Assumes x, y and z values are whatever they are and returns r, g and b in the set [0, 255].
+ (Array) xyzToLab(x, y, z)
+ (Array) xyzToLab(xyz)
Converts a XYZ color value to the CIELAB color space. Formulas are based on http://en.wikipedia.org/wiki/Lab_color_space The reference white point used in the conversion is D65. Assumes x, y and z values are whatever they are and returns L, a and b* values
+ (Array) labToXYZ(l, a, b)
+ (Array) labToXYZ(lab)
Converts a L, a, b* color values from the CIELAB color space to the XYZ color space. Formulas are based on http://en.wikipedia.org/wiki/Lab_color_space
The reference white point used in the conversion is D65. Assumes L, a and b* values are whatever they are and returns x, y and z values.
+ (void) rgbToLab(r, g, b)
Converts L, a, b* back to RGB values.
+ (void) labToRGB(l, a, b)