graphics - JavaScript function to return "n" shades of a given color from (dark to light) -


I would like to get a specific color color series for the tag cloud creation

Say if the user has inserted some color with the values ​​of RGB / HHHHHH , then I would like to write a function f (color, no) code "RGB / HHHHH" These colors will then be useful for displaying different tags with different colors of the same shade for the colors of the different colors, in the light colors from black in light colors to "no". But I want to avoid black and white colors in it.

The following is the example of F ({R: 0, G: 0, B: 255}, 7) which gives the blue color of the code 7 is.

f ({R: 0, g: 0, b: 255}, 7) Returns 7 colors of blue

I do not like the fact that for any RGB combination, for example (25, 150,150) also

Is this function possible to use Javascript or is there a formula for RGB with which it can be obtained?

  function Generate () {var r = document.query selector ("# R"). Value% 256; Var g = document. Query selector ("# g"). Value% 256; Var b = document.query Selection ("#b"). Value% 256; Var str = ""; For (var i = 0; i & lt; 7; i ++) {r + 33; G + = 33; B + = 33; Str + = "
  .swatch {width: 50px; Height: 25px; Margin: 1px}   
  & lt; Div & gt; R & lt; Input type = "text" id = "R" /> gt; & Lt; / Div & gt; & Lt; Div & gt; G & lt; Input type = "article" id = "g" /> gt; & Gt; / Div & gt; & Lt; Div & gt; B & lt; Input type = "article" id = "b" /> & Lt; / Div & gt; & Lt; Input type = "button" onclick = "generated ()" value = "generated" /> & Lt; Div id = "op" & gt; Color of generated color & lt; / Div & gt;     

Do you want something like this? This is a demo that I have created using jQuery.

Tell me if you have any doubts.

Comments