GMU:Processing im Park/Justine Barthel: Difference between revisions

From Medien Wiki
No edit summary
No edit summary
Line 6: Line 6:




Bilder werden in einem Raster angeordnet
* Bilder werden in einem Raster angeordnet


[[File:Park_grid_1.png]]
[[File:Park_grid_1.png]]




Quellcode:
* Quellcode:


<source lang="java">
<source lang="java">
Line 42: Line 42:




Danach wird eine Slideshow erstellt
* Danach wird eine Slideshow erstellt


[[File:wwgvu.gif]]
[[File:wwgvu.gif]]




Quellcode:  
* Quellcode:  


<source lang="java">
<source lang="java">
Line 86: Line 86:
</source> <br>
</source> <br>


Link zu den Bildern: [https://www.flickr.com/photos/138192882@N07/albums/72157663243550165]
* Link zu den Bildern: [https://www.flickr.com/photos/138192882@N07/albums/72157663243550165]




Line 93: Line 93:




Image Slicer
* Image Slicer


[[File:Schick.PNG|300px]]
[[File:Schick.PNG|300px]]




Quellcode:
* Quellcode:


<source lang="java">
<source lang="java">
Line 127: Line 127:




Weitere Bilder  
* Weitere Bilder  


[[File:Unbenannt_2.PNG|300px]]
[[File:Unbenannt_2.PNG|300px]]
[[File:Unbenannt_1.PNG|300px]]
[[File:Unbenannt_1.PNG|300px]]


Link zu den Bildern: [https://www.flickr.com/photos/138192882@N07/albums/72157663695511395]
* Link zu den Bildern: [https://www.flickr.com/photos/138192882@N07/albums/72157663695511395]


   
   
Line 138: Line 138:




Brush
* Brush


[[File:Unbenannt_3.PNG| 500px]]
[[File:Unbenannt_3.PNG| 500px]]




Quellcode
* Quellcode


<source lang="java">
<source lang="java">
Line 185: Line 185:


Coming soon
Coming soon
=='''Hausaufgabe 5''' ==
* Pixel Sorting
* Ursprüngliches Bild
[[File:Sonne_02.PNG| 300px]]
* Quellcode für dieses Bild (Ich habe mit dem ursprünglichen Bild begonnen und dann den Quellcode immer wieder verändert.)
[[File:Pixelsorting_05.PNG| 300px]]
<source lang="java">
PImage img;
int id = 1;
int sortMode = 1;
void setup() {
  size(500, 500);
  reset();
}
void reset() {
    img = loadImage("IMG_001.jpg");
}
void draw() {
  img.loadPixels();
  color[] pxls = img.pixels;
  switch(sortMode) {
    case 1:
      sortLeft(pxls);
      break;
    case 2:
      sortDown(pxls);
      break;
    case 3:
      sortUp(pxls);
      break;
  }
  img.updatePixels();
  image(img, 0, 0, 500, 500);
}
void sortLeft(color[] pxls) {
  for(int y = 400; y < height; y++) {
    for(int x = 400; x < width-1 ; x++) {
      int left = y * img.height + x;
      int right = x * img.width + (x+50);
      int posx = mouseX - width / 2;
      if(green(pxls[right]) - green(pxls[left]) < posx) {
          color tmp= pxls[left];
          pxls[left] = pxls[right];
          pxls[right] = tmp;
      } 
    }
  }
}
void sortDown(color[] pxls) {
  for(int x = 450; x < width; x++) {
    for(int y = height - 20; y > 0 ; y--) {
      int top = y * img.height + x;
      int bottom = (y+1) * img.width + x;
      int posx = mouseX - width / 10;
      if(green(pxls[top]) - green(pxls[bottom]) < posx) {
          color tmp= pxls[top];
          pxls[top] = pxls[bottom];
          pxls[bottom] = tmp;
      } 
    }
  }
}
void sortUp(color[] pxls) {
  for(int x = 90; x < width; x++) {
    for(int y = 50; y < height +5 ; y++) {
      int top = y * img.height + 6;
      int bottom = (y+1) * img.width + x;
      int posx = mouseY - height / 2;
      if(green(pxls[top]) - green(pxls[bottom]) < posx) {
          color tmp= pxls[bottom];
          pxls[bottom] = pxls[top];
          pxls[top] = tmp;
      } 
    }
  }
}
void keyPressed() {
  switch(key) {
    case ' ': 
      reset();
      break;
    case '1':
      sortMode = 1;
      break;
    case '2':
    sortMode = 2;
    break;
    case '3':
    sortMode = 3;
    break;
  }
}
</source> <br>
* Weitere Bilder
[[File:Pixelsorting_01.PNG| 300px]]
[[File:Pixelsorting_02.PNG| 300px]]
[[File:Pixelsorting_04.PNG| 300px]]
[[File:Pixelsorting_03.PNG| 300px]]