Setting HSV colors with JavaScript

1. In Global JavaScript
function ggbOnInit() {}[br][br]// Sets HSV colors instead of RGB[br]// @param h, s, v[br]// @return r, g, b normalized values for the HSV scheme color[br]function setHSV(h, s, v) {[br] var r, g, b, i, f, p, q, t;[br] i = Math.floor(h * 6);[br] f = h * 6 - i;[br] p = v * (1 - s);[br] q = v * (1 - f * s);[br] t = v * (1 - (1 - f) * s);[br] switch (i % 6) {[br] case 0:[br] r = v, g = t, b = p;[br] break;[br] case 1:[br] r = q, g = v, b = p;[br] break;[br] case 2:[br] r = p, g = v, b = t;[br] break;[br] case 3:[br] r = p, g = q, b = v;[br] break;[br] case 4:[br] r = t, g = p, b = v;[br] break;[br] case 5:[br] r = v, g = p, b = q;[br] break;[br] }[br] var n = 255;[br] return [Math.round(r * n) / n, Math.round(g * n) / n, Math.round(b * n) / n];[br]}
2. Create button "SetColors" with JavaScript
var h = ggbApplet.getValue('h'); // Get value "hue"[br]var s = ggbApplet.getValue('s'); // Get value "sat"[br]var v = ggbApplet.getValue('v'); // Get value "val"[br][br]var colors = setHSV(h, s, v); // Store hsv colors[br][br]// Now set color in RGB[br]ggbApplet.evalCommand("SetValue(r, " + colors[0] + ")");[br]ggbApplet.evalCommand("SetValue(g, " + colors[1] + ")");[br]ggbApplet.evalCommand("SetValue(b, " + colors[2] + ")");
3. Update values in sliders h, s and v
RunClickScript( SetColors )

Information: Setting HSV colors with JavaScript