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

    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;
    }

    if (s === 0) {
        color[0] = color[1] = color[2] = l; // achromatic
    }
    else {
        var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
        var p = 2 * l - q;
        color[0] = hue2rgb(p, q, h + 1/3);
        color[1] = hue2rgb(p, q, h);
        color[2] = hue2rgb(p, q, h - 1/3);
    }

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

    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;
    }

    if (s === 0) {
        color[0] = color[1] = color[2] = l; // achromatic
    }
    else {
        var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
        var p = 2 * l - q;
        color[0] = hue2rgb(p, q, h + 1/3);
        color[1] = hue2rgb(p, q, h);
        color[2] = hue2rgb(p, q, h - 1/3);
    }

    color[3] = a;
    return color;
}
function setHSL ( color , h , s , l , a ) { a = a || 1 ; 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 ; } if ( s === 0 ) { color [ 0 ] = color [ 1 ] = color [ 2 ] = l ; // achromatic } else { var q = l < 0.5 ? l * ( 1 + s ) : l + s - l * s ; var p = 2 * l - q ; color [ 0 ] = hue2rgb ( p , q , h + 1 / 3 ) ; color [ 1 ] = hue2rgb ( p , q , h ) ; color [ 2 ] = hue2rgb ( p , q , h - 1 / 3 ) ; } color [ 3 ] = a ; return color ; }
Updates a color based on hue, saturation, lightness 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} l - lightness (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 lightness and alpha