title: How to increment / decrement hex color values with javascript / jQuery
body: <p>Is it possible to increment or decrement hex color values on a step-by-step basis in jQuery / javascript? </p>
  
  <p>What I would like to do is something like this: </p>
  
  <p>Adapting from a for-loop like </p>
  
  <pre><code>for (var i = 0; i &lt;= 100; i++) {
      console.log(i);
  }
  </code></pre>
  
  <p>I would like to do something like </p>
  
  <pre><code>for (var color = 000000; color &lt;= ffffff; color++) {
      console.log(color);
  }
  </code></pre>
  
  <p>without any conversion. </p>
  
  <p>Is that possible? I've allready tried this: </p>
  
  <pre><code>for (var color = parseInt('000000', 16); color &lt;= parseInt('ffffff', 16); color++){
      console.log(color.toString(16));
  }
  </code></pre>
  
  <p>and it works but it's terribly slow (I get the warning that the script is slowing down the website and if I want to stop the script).</p>
  
  <p>The reason why I want to do this:
  I would like to change the color stops of svg gradients in a certain interval. If I had for example this svg (simplified):</p>
  
  <pre><code>&lt;svg&gt;
      ...
      &lt;linearGradient&gt;
          &lt;stop offset="0%"  stop-color="#C8E3EF"/&gt;
          &lt;stop offset="100%"  stop-color="#C8E3EF"/&gt;
      &lt;/linearGradient&gt;
      ...
  &lt;/svg&gt;
  </code></pre>
  
  <p>This gradient would of course appear as a solid color. Now I want to change it step by step to for example </p>
  
  <pre><code>&lt;svg&gt;
      ...
      &lt;linearGradient&gt;
          &lt;stop offset="0%"  stop-color="#dfcf99"/&gt;
          &lt;stop offset="100%"  stop-color="#c5b6ec"/&gt;
      &lt;/linearGradient&gt;
      ...
  &lt;/svg&gt;
  </code></pre>
  
  <p>At each step or interval I want to go one value closer to the target color (through addition/substraction). In the end the result should be a smooth color-animation. Is that possible without the conversion? It does not have to be a for-loop btw., I just chose it to illustrate my idea.</p>