Einblick in die generative Gestaltung mit «Processing»

Sechs Kursabende à vier Stunden an der EB Zürich

Kurskonzeption und Leitung Hanna Züllig


< back

						/*
Autorin: Salome Rinderknecht
Kurs: Einblick in die generative Gestaltung mit processing ip971231
Kursleitung: Hanna Zuellig
Veroeffentlicht unter der creative common license Attribution-NonCommercial-ShareAlike
CC BY-NC-SA  http://creativecommons.org/licenses/
*/

float[] x;


color c;
int radiusx = 10;
int radiusy = 10;
float y = 110;
float xspeed = random(2);
float yspeed = random(3);
int xdirection = 1;
int ydirection = 1;

void setup() {
  size(500,500);
  ellipseMode(RADIUS);
  smooth();
  noFill();
  strokeWeight(5);
  
  x = new float [10];
  for (int i = 0; i < x.length; i++) {
  x[i] = random(width);
}


    
}
  
void draw() {
  background(255);
  
  for (int i = 0; i < x.length; i++) {
  
  x[i] += xspeed * xdirection;
  y += yspeed * ydirection;
  if ((x[i] > width - 10) ||  (x[i] < 10)){
  xdirection = -xdirection;
  }
 
  if ((x[i] == width - 10) ||  (x[i] == 10)){
  radiusx = 6;
  }
  else {
   radiusx = 10; 
  }
    
  if ((y > height - 10) ||  (y < 10)){
  ydirection = -ydirection;
  }
 
  if ((y == height - 10) ||  (y == 10)){
  radiusy = 6;
  }
  else {
   radiusy = 10; 
  }
  ellipse(x[i],y,radiusx,radiusy);


// Kreise anhalten, wenn sie auf Mauszeiger treffen
  
/*  float d = dist(mouseX, mouseY, x[i], y); 
  if (d < 10) {
   xspeed = 0;
  yspeed = 0; 
  }
  
    else  {
   xspeed = 5;
  yspeed = 4; 
  } */
  
  if(mousePressed){
    saveFrame("Salome.jpg");
    
  }
  
 }
   
 }