|
|
@ -202,15 +202,38 @@ var parseColor = exports.parseColor = function(str){ |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// adapted from ABC code at http://www.w3.org/TR/css3-color/#hsl-color
|
|
|
|
/** |
|
|
|
* HSLA -> RGB. |
|
|
|
* |
|
|
|
* @param {Number} h |
|
|
|
* @param {Number} s |
|
|
|
* @param {Number} l |
|
|
|
* @param {Number} a |
|
|
|
* @return {Array} |
|
|
|
* @api private |
|
|
|
*/ |
|
|
|
|
|
|
|
function hsl2rgb(h,s,l,a) { |
|
|
|
var m2 = l <= 0.5 ? l*(s+1) : l+s-l*s |
|
|
|
, m1 = l*2-m2; |
|
|
|
return [ Math.round(hue2rgb(m1, m2, h+1/3) * 255), |
|
|
|
Math.round(hue2rgb(m1, m2, h) * 255), |
|
|
|
Math.round(hue2rgb(m1, m2, h-1/3) * 255), |
|
|
|
a ] |
|
|
|
return [ |
|
|
|
Math.round(hue2rgb(m1, m2, h+1/3) * 255) |
|
|
|
, Math.round(hue2rgb(m1, m2, h) * 255) |
|
|
|
, Math.round(hue2rgb(m1, m2, h-1/3) * 255) |
|
|
|
, a |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Hue to RGB |
|
|
|
* |
|
|
|
* @param {Number} m1 |
|
|
|
* @param {Number} m2 |
|
|
|
* @param {Number} h |
|
|
|
* @return {Number} |
|
|
|
* @api private |
|
|
|
*/ |
|
|
|
|
|
|
|
function hue2rgb(m1,m2,h) { |
|
|
|
if (h<0) h = h+1; |
|
|
|
if (h>1) h = h-1; |
|
|
|