Einblick in die generative Gestaltung mit «Processing»

Sechs Kursabende à vier Stunden an der EB Zürich

Kurskonzeption und Leitung Hanna Züllig


< back

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

/* @pjs preload="sketches/kurstag04/Marcel_k/data/marcel-kuster_bg_27.jpg"; */

PImage img; // Source image
int kachel=10; //Kachelgrössen

void setup() {
  size(800,500);
  img = loadImage("sketches/kurstag04/Marcel_k/data/marcel-kuster_bg_27.jpg");
  //fill(0);
  smooth();
  background(255);
  noStroke();
}

void draw() {
  //background(255);
  
  img.loadPixels();
  shapeMode(CENTER);
  
  
  for (int x = 0; x < width; x+=kachel ) {
    for (int y = 0; y < height; y+=kachel ) {
      
      // Pixel location and color
      int loc = x + y*img.width; //Ergibt Nummer des Pixels (Position)
      color pix = img.pixels[loc]; //Pixelwert wird ausgewählt
      //println(pix);
      fill(pix/2,50);
      
      float gray=brightness(pix);
      ellipse(x,y,gray/10,gray/10); //Hellere Punkte grösser
      
      if(mousePressed){
        stroke(pix/2);
        strokeWeight(gray/100);
        line(mouseX,mouseY,x+kachel, y+kachel);
      }
    }
  }
  
  
  if(keyPressed){
    if(key=='s'){
    saveFrame("Marcel_k.png");
    }
  }
  
}