index.js
function setHSV(color, h, s, v, a) {
  a = a || 1;

  var i = Math.floor(h * 6);
  var f = h * 6 - i;
  var p = v * (1 - s);
  var q = v * (1 - f * s);
  var t = v * (1 - (1 - f) * s);

  switch (i % 6) {
    case 0: color[0] = v; color[1] = t; color[2] = p; break;
    case 1: color[0] = q; color[1] = v; color[2] = p; break;
    case 2: color[0] = p; color[1] = v; color[2] = t; break;
    case 3: color[0] = p; color[1] = q; color[2] = v; break;
    case 4: color[0] = t; color[1] = p; color[2] = v; break;
    case 5: color[0] = v; color[1] = p; color[2] = q; break;
  }

  color[3] = a;
  return color;
}
function setHSV(color, h, s, v, a) {
  a = a || 1;

  var i = Math.floor(h * 6);
  var f = h * 6 - i;
  var p = v * (1 - s);
  var q = v * (1 - f * s);
  var t = v * (1 - (1 - f) * s);

  switch (i % 6) {
    case 0: color[0] = v; color[1] = t; color[2] = p; break;
    case 1: color[0] = q; color[1] = v; color[2] = p; break;
    case 2: color[0] = p; color[1] = v; color[2] = t; break;
    case 3: color[0] = p; color[1] = q; color[2] = v; break;
    case 4: color[0] = t; color[1] = p; color[2] = v; break;
    case 5: color[0] = v; color[1] = p; color[2] = q; break;
  }

  color[3] = a;
  return color;
}
function setHSV ( color , h , s , v , a ) { a = a || 1 ; var i = Math . floor ( h * 6 ) ; var f = h * 6 - i ; var p = v * ( 1 - s ) ; var q = v * ( 1 - f * s ) ; var t = v * ( 1 - ( 1 - f ) * s ) ; switch ( i % 6 ) { case 0 : color [ 0 ] = v ; color [ 1 ] = t ; color [ 2 ] = p ; break ; case 1 : color [ 0 ] = q ; color [ 1 ] = v ; color [ 2 ] = p ; break ; case 2 : color [ 0 ] = p ; color [ 1 ] = v ; color [ 2 ] = t ; break ; case 3 : color [ 0 ] = p ; color [ 1 ] = q ; color [ 2 ] = v ; break ; case 4 : color [ 0 ] = t ; color [ 1 ] = p ; color [ 2 ] = v ; break ; case 5 : color [ 0 ] = v ; color [ 1 ] = p ; color [ 2 ] = q ; break ; } color [ 3 ] = a ; return color ; }
Updates a color based on hue, saturation, value and alpha
@param  {Array} color   - RGBA color array [r,g,b,a] to update
@param  {Number} h - hue (0..1)
@param  {Number} s - saturation (0..1)
@param  {Number} v - value (0..1)
@param  {Number} [a=1] - alpha (0..1)
@return {Array}    - updated RGBA color array [r,g,b,a] (0..1)
Updates a color based on hue saturation value and alpha