radial fills

hey there… moving over from a max/msp & processing environment and trying to work out some things in OF. Was interesting mainly in generative art, starting small, and will get into some of the bigger ideas as I go.

looking to generate some 2D radial fills, first with just normal circles, then I would like to extend that into possible shapes, such as the heart made out of ofBezierVertex points found in the api documentation. I have an old gradient trick from processing, but stuck on a few things.

Processing Code Example:

  
void setup(){  
  size(800, 800);  
  background(0);  
  smooth();  
  
  // create a simple table of gradients  
  int columns = 2;  
  int radius = (width/columns)/2;  
  // create some gradients  
  for (int i=radius; i< width; i+=radius*2){  
    for (int j =radius; j< height; j+=radius*2){  
      createGradient(i, j, radius,   
      color(255,0,0),   
      color(int(random(255)), int(random(255)), int(random(255))));  
    }  
  }  
}  
  
void createGradient (float x, float y, float radius, color c1, color c2){  
  float px = 0, py = 0, angle = 0;  
  
  // calculate differences between color components   
  float deltaR = red(c2)-red(c1);  
  float deltaG = green(c2)-green(c1)-100;  
  float deltaB = blue(c2)-blue(c1)-100;  
  // hack to ensure there are no holes in gradient  
  // needs to be increased, as radius increases  
  float gapFiller = 16.0;  
  
  for (int i=0; i< radius; i++){  
    for (float j=0; j<360; j+=1.0/gapFiller){  
      px = x+cos(radians(angle))*i;  
      py = y+sin(radians(angle))*i;  
      angle+=1.0/gapFiller;  
      color c = color(  
      (red(c1)+(i)*(deltaR/radius)),  
      (green(c1)+(i)*(deltaG/radius)),  
      (blue(c1)+(i)*(deltaB/radius))   
        );  
        set(int(px), int(py), c);        
    }  
  }  
  // adds smooth edge   
  // hack anti-aliasing  
  noFill();  
  strokeWeight(3);  
  ellipse(x, y, radius*2, radius*2);  
}  
  

the part that stumps me in making this work in OF is the set function. In processing, this is a way to set a specific pixel’s color. What would be the equivalent OF call?

Also, there has to be a better way to do this. I know that there are a few dumb things in the code example such as not calculating the color in the for loop since it is the same at any given radius and such, but I was hoping there was a better way to do gradients in general.

Past that, what would be the best way to fill a shape like that?

Thanks for any help… I am all googled out.