Thursday, May 3, 2012

Processing

I finally got around to trying out Processing a couple of days ago, a programming language for making… well, art.  It’s like a super-simplified Java geared toward graphics and animation.  Needless to say, I became an instant fan. 

Here’s my first program - a Pickover attractor.

1-Fullscreen capture 522012 93119 PM
//Definition
//xn+1 = sin(a yn) + c cos(a xn)
//yn+1 = sin(b xn) + d cos(b yn)
//where a, b, c, d are variabies that 
//define each attractor. 

void setup(){
  size(700,600);
  translate(width/2,height/2);
  background(0,0,33);
  noStroke();
}
 
float x = 0; 
float y = 0;
float a = -1.4;
float b = 1.6;
float c = 1.0;
float d = 0.7;
float newx = 0;
float newy = 0;

void draw(){

  for(float z = 1; z < 100; z++){
    fill(100,100,100,10);
    ellipse(170*x+width/2-40,170*y+height/2-20,3 ,3);
    
    newx = sin(a*y) + c*cos(a*x);
    newy = sin(b*x) + d*cos(b*y);

    x = newx;
    y = newy;
  }
    
}

No comments:

Post a Comment