public/rot.js/rot.js
function(color) {
		var l = color[2];

		if (color[1] == 0) {
			l = Math.round(l*255);
			return [l, l, l];
		} else {
			function hue2rgb(p, q, t) {
				if (t < 0) t += 1;
				if (t > 1) t -= 1;
				if (t < 1/6) return p + (q - p) * 6 * t;
				if (t < 1/2) return q;
				if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
				return p;
			}

			var s = color[1];
			var q = (l < 0.5 ? l * (1 + s) : l + s - l * s);
			var p = 2 * l - q;
			var r = hue2rgb(p, q, color[0] + 1/3);
			var g = hue2rgb(p, q, color[0]);
			var b = hue2rgb(p, q, color[0] - 1/3);
			return [Math.round(r*255), Math.round(g*255), Math.round(b*255)];
		}
	}
function(color) {
		var l = color[2];

		if (color[1] == 0) {
			l = Math.round(l*255);
			return [l, l, l];
		} else {
			function hue2rgb(p, q, t) {
				if (t < 0) t += 1;
				if (t > 1) t -= 1;
				if (t < 1/6) return p + (q - p) * 6 * t;
				if (t < 1/2) return q;
				if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
				return p;
			}

			var s = color[1];
			var q = (l < 0.5 ? l * (1 + s) : l + s - l * s);
			var p = 2 * l - q;
			var r = hue2rgb(p, q, color[0] + 1/3);
			var g = hue2rgb(p, q, color[0]);
			var b = hue2rgb(p, q, color[0] - 1/3);
			return [Math.round(r*255), Math.round(g*255), Math.round(b*255)];
		}
	}
function ( color ) { var l = color [ 2 ] ; if ( color [ 1 ] == 0 ) { l = Math . round ( l * 255 ) ; return [ l , l , l ] ; } else { function hue2rgb ( p , q , t ) { if ( t < 0 ) t += 1 ; if ( t > 1 ) t -= 1 ; if ( t < 1 / 6 ) return p + ( q - p ) * 6 * t ; if ( t < 1 / 2 ) return q ; if ( t < 2 / 3 ) return p + ( q - p ) * ( 2 / 3 - t ) * 6 ; return p ; } var s = color [ 1 ] ; var q = ( l < 0.5 ? l * ( 1 + s ) : l + s - l * s ) ; var p = 2 * l - q ; var r = hue2rgb ( p , q , color [ 0 ] + 1 / 3 ) ; var g = hue2rgb ( p , q , color [ 0 ] ) ; var b = hue2rgb ( p , q , color [ 0 ] - 1 / 3 ) ; return [ Math . round ( r * 255 ) , Math . round ( g * 255 ) , Math . round ( b * 255 ) ] ; } }
Converts an HSL color value to RGB. Expects 0..1 inputs, produces 0..255 outputs.
@param {number[]} color
@returns {number[]}
Converts an HSL color value to RGB . Expects 0 .. 1 inputs produces 0 .. 255 outputs .