title: Processing: efficiently drawing a gradient
body: <p>I'm new to <a href="http://processing.org/reference/" rel="nofollow">Processing</a> and I've been working on simulating electron motion. 
  Everything seems fine until I'm try to add a gradient color to each particle.The frame rate drops considerably. </p>
  
  <p>Here is what I've tried so far:</p>
  
  <pre><code>float a=0;
  float s;
  void setup()
  {
    size(500,500);
    smooth();
    frameRate(500);
    colorMode(HSB,360,100,100);
    noStroke();
    ellipseMode(RADIUS);
  }
  
  void draw()
  {
    background(200,0,100);
    pushMatrix();
    translate(width/2, height/2);
    rotate(radians(-18));
    for ( int r = width ; r &gt;= 0; r = r - 1 )
    {
      s = 500*exp(-r);
      fill(202, s, 100);
      ellipse(100*cos(a), 50*sin(a), r, r);
  
    }
    a+=0.1;
    popMatrix();
  }
  </code></pre>