
function hsv2rgb(h, s, v) {
	var r, i, f, p, q, t;
	i = Math.floor(h / 60) % 6;
	f = (h / 60) - i;
	p = v * (1 - s);
	q = v * (1 - f * s);
	t = v * (1 - (1 - f) * s);
	switch (i) {
		case 0: return [Math.floor(v * 255), Math.floor(t * 255), Math.floor(p * 255)];
		case 1: return [Math.floor(q * 255), Math.floor(v * 255), Math.floor(p * 255)];
		case 2: return [Math.floor(p * 255), Math.floor(v * 255), Math.floor(t * 255)];
		case 3: return [Math.floor(p * 255), Math.floor(q * 255), Math.floor(v * 255)];
		case 4: return [Math.floor(t * 255), Math.floor(p * 255), Math.floor(v * 255)];
		case 5: return [Math.floor(v * 255), Math.floor(p * 255), Math.floor(q * 255)];
	}
}
