Einblick in die generative Gestaltung mit «Processing»

Sechs Kursabende à vier Stunden an der EB Zürich

Kurskonzeption und Leitung Hanna Züllig


< back

						

int NORTH = 0;
int NORTHEAST = 1; 
int EAST = 2;
int SOUTHEAST = 3;
int SOUTH = 4;
int SOUTHWEST = 5;
int WEST = 6;
int NORTHWEST= 7;

float stepSize = 30;
float diameter = 40;

int direction;
float posX, posY;


PImage bgbild;

void setup() {
  size(500, 500);
  background(255);
  smooth();
  noStroke();
  frameRate(7);
  posX = width/2;
  posY = height/2;
 
  bgbild=loadImage("img_collage.jpg");
  
}


void draw() {
 
    direction = (int) random(0, 8);

    if (direction == NORTH) {  
      posY -= stepSize;  
    } 
    else if (direction == NORTHEAST) {
      posX += stepSize;
      posY -= stepSize;
    } 
    else if (direction == EAST) {
      posX += stepSize;
    } 
    else if (direction == SOUTHEAST) {
      posX += stepSize;
      posY += stepSize;
    }
    else if (direction == SOUTH) {
      posY += stepSize;
    }
    else if (direction == SOUTHWEST) {
      posX -= stepSize;
      posY += stepSize;
    }
    else if (direction == WEST) {
      posX -= stepSize;
    }
    else if (direction == NORTHWEST) {
      posX -= stepSize;
      posY -= stepSize;
    }

    if (posX > width) posX = 0;
    if (posX < 0) posX = width;
    if (posY < 0) posY = height;
    if (posY > height) posY = 0;
    
    
     color c = bgbild.get(int(posX), int(posY));
     fill(c, 1);
     rect(0, 0, width, height);
     fill(c, 45);
     ellipse(posX, posY, diameter, diameter);
     
     
     if(frameCount==100){
       saveFrame("Ruth.jpg");
       
     }
 
}