Thursday, May 29, 2008

Proccesing - Sparkling Stars

Processing is a wonderful environment for those who like to experiment
with design and graphics and sound
It has been created by artists for artists.

float posx = 250;
float posy = 250;
int numstars = 36;

Star[] p = new Star[numstars];

class Star {
  float x;
  float y;
  Star(float _x, float _y) {
    x = _x;
    y = _y;        
  }

  void moveTo(float _x,float _y){
    x = _x;
    y=_y;
    for (float i=0; i<360 ;i+=4){
      stroke(random(255)+245,random(255)+245,random(12)+245,random(30));
      line(x,y,random(40)*cos(i)+x,random(40)*sin(i)+y);      
    }  
  }
}

void setup(){
  size(800,800);
  smooth();
  noStroke();
  for (int i=0; i<numstars; i++){
    p[i] = new Star(100,100);
  }
}

void draw(){
  background(0,0,30);
  for (int i=0; i<numstars; i++){
    posx = random(width);
    posy=random(height);  
    p[i].moveTo(posx,posy);
  }
  
}