GMU:Processing im Park/Dirk Wäsch: Difference between revisions

From Medien Wiki
Line 177: Line 177:
<br style="clear:both;">
<br style="clear:both;">


Processing v2.1.1 Quellcode:
[http://www.uni-weimar.de/medien/wiki/index.php5?title=GMU:Processing_im_Park/Dirk_Wäsch/Code_Hausaufgabe_V Processing v2.1.1 Quellcode]
<br>
<source lang="java">
import ddf.minim.*;
Minim minim;
PImage img1;
int n=3;
int activeLocation = -1;
AudioPlayer[] players = new AudioPlayer[n];
int[][] locations = {
  {355, 40, 20},
  {335, 165, 20},
  {210, 320, 20},
};
 
void setup() {
minim = new Minim(this);
size(400,600);
img1 = loadImage("https://c2.staticflickr.com/2/1686/24438648251_853287b12c_z.jpg");
  for(int i=0; i<n; i++){
  players[i] = minim.loadFile("http://waesch.host56.com/ablage/sound/Park" + (i+1) + ".mp3");
  }
}
 
void draw() {
  image(img1,0,0,400,600);
  fill(225,150);
  noStroke();
  for(int i=0; i < locations.length; i++){
  int[] loc =locations[i];
  int x= loc[0];
  int y= loc[1];
  int r= loc[2];
if(atLocation(x,y,r)){
  activeLocation = i;
    ellipse(x, y, 2*r, 2*r);
  }
  if(playingLocation(i)){
    ellipse( x,y,2*r,2*r);
  }
  }
}
boolean atLocation(int x, int y, int r){
      return dist(x,y,mouseX,mouseY)<r;
}
boolean playingLocation(int i){
  return players[i].isPlaying();
}
void mousePressed(){
if(activeLocation !=-1){
  for (int i=0; i<n; i++) {
  players[i].pause();
  }
  println("Sound " + (activeLocation + 1));
  println(mouseX, mouseY);
  players[activeLocation].rewind();
  players[activeLocation].play();
}
}
 
void keyPressed(){
  for(int i=0; i<n; i++){
    players[i].pause();
  }
  int i = (key - '1');
  if(i>= 0 && i<n){
  println("Sound " + (i+1));
  players[i].rewind();
  players[i].play();
  }
}
</source><br>


== Proccesing - Workshop-Wochenende II - Video & Sound ==
== Proccesing - Workshop-Wochenende II - Video & Sound ==

Revision as of 11:14, 28 January 2016

Dirk Wäsch

Meine Seite zum Kurs "Processing im Park".

Ausflug - Ilmpark

Fotos im Ilmpark: Bild-Uploads auf Flickr


Hausaufgabe I

  • Diese Fotos haben wir zunächst als Slideshow animiert.
Park animation 400 225.gif



Beispiel in ProcessingJS

Processing v3.0.0 Quellcode

Hausaufgabe II

  • Image-Slicer
Image slicer 720 405.png

Wxy0e-.gif


Processing v3.0.0 Quellcode

Hausaufgabe III

  • Animierter Mauszeiger
Brush animation 720 405.png

ta1xeo.gif


Processing v3.0.0 Quellcode

Ausflug - Schlosspark Belvedere

Hausaufgabe IV

  • Pixel

Inhalt folgt später.

Proccesing - Workshop-Wochenende I - Video & Sound

Sounds aus der Parkhöhle:

Ventilation: <flashmp3 id="Park3.mp3">http://waesch.host56.com/ablage/sound/Park1.mp3</flashmp3>
Seismische Kammer: <flashmp3 id="Park3.mp3">http://waesch.host56.com/ablage/sound/Park2.mp3</flashmp3>
Automatische Tür: <flashmp3 id="Park3.mp3">http://waesch.host56.com/ablage/sound/Park3.mp3</flashmp3>

Hausaufgabe V

  • Soundboard

Beim Spazieren durch die Weimarer Parkhöhle

Parkhoehle .png


Processing v2.1.1 Quellcode

Proccesing - Workshop-Wochenende II - Video & Sound

Fotos bei der Mensa am Park: Bild-Uploads auf Flickr


  • Pixel Sorting

Sortierung der Pixel nach Farbton

Sorting_250.png


Processing v3.0.1 Quellcode:

PImage img;
int d = 50;
PImage[] tiles;
int rows, cols, n;
 
void setup() {
  size(1000, 500);
  img = loadImage("https://c2.staticflickr.com/2/1449/24331989911_1044424084_k.jpg");
  cols = (img.width/d);
  rows = (img.height/d);
  n = cols * rows;
  tiles = new PImage[n];
  for (int i = 0; i < n; i++) {
    int x = d * (i % cols);
    int y = d * (i / cols);
    tiles[i] = img.get(x, y, d, d);
  }
}
 

void draw() {
   sort(tiles);
   // show tiles
   for(int i = 0; i < n; i++) {
 
     PImage tile = tiles[i];
 
     int y = d * (i / cols);
     int x = d * (i % cols);
 
     image(tile, x, y, d, d);
 
   }
 
}
 
void sort(PImage[] tiles) {
 
  for(int y = 0; y < rows; y++) {
    for(int x = 0; x < cols-1; x++) {
 
      int pos1 = y * cols + x;
      int pos2 = y * cols + (x+1);
 
      PImage tile1 = tiles[pos1];
      PImage tile2 = tiles[pos2];
 
      if( hue(average(tile1)) - hue(average(tile2)) > mouseX ) {
        PImage tmptile = tiles[pos1];
        tiles[pos1] = tiles[pos2];    
        tiles[pos2] = tmptile;
      }
 
    }
  }
}

color average(PImage img) { 
  img.loadPixels();
  color[] pxls = img.pixels;
 
  float r = 0, g = 0, b = 0;
  int n = pxls.length;
 
  for(int i = 0; i < n; i++) {
    color c = pxls[i];
    r += red(c);
    g += green(c);
    b += blue(c);
  }
  color average = color(r/n, g/n, b/n);
  return average;
}


Hausaufgabe VI

  • Butterfly-Webcam

Die Kamera wird in der Mitte gespiegelt
VIDEO

Processing v2.1.1 Quellcode:

code


Hausaufgabe VII

  • Video-Processing

Beim Spazieren im Schlosspark Belvedere habe ich meine Füße gefilmt, wie sie sich auf dem verschiedenen Untergrund bewegen.
VIDEO

Processing v2.1.1 Quellcode:

code



Hausaufgabe VIII

  • Labyrinth



VIDEO

Processing v2.1.1 Quellcode:

code