Search code examples
javascriptjquerycolors

Get shades of Color in Javascript or jQuery?


Is there a way in Javascript or jQuery that we can get all shades of a color and then return the values into an array? Thank you very much.

Something like:

enter image description here


Solution

  • Do you mean something like this?

    var r = 40 % 256;
    var g = 40 % 256;
    var b = 50 % 256;
    var result = [];
    
    for(var i = 0; i < 7; i++)
    {
        r += 33;
        g += 33;
        b += 33;
        result.push(r + "," + g + "," + b);
    }
      
    console.log(result);