title: Create Linear Gradient for a given HEX value in Javascript
body: <p>I am using a linear gradient background image to paint a DIV background.</p>
  
  <pre><code>background-image: linear-gradient(to bottom,  #cdeb8f 0%,#a5c955 100%); 
  </code></pre>
  
  <p>Linear gradient looks good better than a simple background color. Is it possible to create this kind of linear gradients by javascript for a given HEX color?</p>
  
  <p>I mean I want to pass a HEX color value to a function as parameter and it should return me a lighter or darker HEX color so that I can create the above good looking gradient. </p>
  
  <p>Given as above, if I pass </p>
  
  <pre><code>#cdeb8f 
  </code></pre>
  
  <p>it should return me </p>
  
  <pre><code>#a5c955
  </code></pre>
  
  <p>I converted above HEX values into Decimals and found that they have a 1.24 ratio. I then used a function to convert passed HEX into Decimal, multiplying or dividing it by 1.24 and convert back to HEX. Return HEX color did not create a meaningful linear gradient with the passed HEX color.</p>
  
  <p>The main problem is to keep the above proportion so that the linear gradient does not look weird.</p>