title: Algorithm to Generate WaveLength Color Gradient in C#
body: <p>I am trying to generate the below Color Gradient ( the Color is blue at one end, and red at the other). </p>
  
  <p><a href="https://i.stack.imgur.com/dkOxM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dkOxM.jpg" alt="alt text"></a><br>
  <sub>(source: <a href="http://img.brothersoft.com/screenshots/softimage/w/wavelength-160945-1.jpeg" rel="nofollow noreferrer">brothersoft.com</a>)</sub>  </p>
  
  <p>I follow the suggestion <a href="https://stackoverflow.com/questions/2011832/generate-color-gradient-in-c/2011839#2011839">put forth here</a>. This is my code:</p>
  
  <pre><code>int rMax = Color.Red.R;
  int rMin = Color.Blue.R;
  // ... and for B, G
  var colorList = new List&lt;Color&gt;();
  for(int i=0; i&lt;size; i++)
  {
      var rAverage = rMin + (int)((rMax - rMin) * i / size);
      // ... and for B, G
      colorList.Add(Color.FromArgb(rAverage, gAverage, bAverage));
  }
  </code></pre>
  
  <p>Although the result I <em>did</em> show a gradual, smooth transition from Red to Blue, but other intermediate color such as yellow and green didn't show up at all.</p>
  
  <p>Anything I did wrong?</p>