function rgb2hsl(rgb) {
	var r = rgb.r, g = rgb.g, b = rgb.b;
	r /= 255; g /= 255; b /= 255;
	var max = Math.max(r, g, b), min = Math.min(r, g, b);
	var h, s, l = (max + min) / 2;

	if (max === min) {
		h = s = 0; // achromatic
	} else {
		var d = max - min;
		s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
		switch (max) {
			case r: h = (g - b) / d + (g < b ? 6 : 0); break;
			case g: h = (b - r) / d + 2; break;
			case b: h = (r - g) / d + 4; break;
		}
		h /= 6;
	}

	return { h: h, s: s, l: l };
}
Converts an RGB color value to HSL. Conversion formula adapted from
http://en.wikipedia.org/wiki/HSL_color_space. This function adapted
from http://stackoverflow.com/a/9493060.
Assumes r, g, and b are contained in the set [0, 255] and
returns h, s, and l in the set [0, 1].

@param   Object  rgb     RGB as r, g, and b keys
@return  Object          HSL as h, s, and l keys