GMU:Processing im Park/Jason Langheim: Difference between revisions

From Medien Wiki
Line 76: Line 76:


== Homework 3 ==
== Homework 3 ==
<source lang="java">
PImage[] images = new PImage[19];
PImage alpha;
int w=100;
int h;
void setup() {
  size(400, 500);
  frameRate(10);
  background(255);
  for (int i = 0 ; i < images.length; i++)
  {
    images [i] = loadImage("IMG_0" + (701 + i) + ".JPG");
    alpha = loadImage("alphamask.gif");
    images [i].mask(alpha);
    images [i].resize(100, 100);
    println(i);
  }
 
 
}
void draw()
{
  if(mousePressed){
    int counter = frameCount % 19;
  image(images[counter], mouseX - 50, mouseY - 50);
  }
}
</source>
http://cdn.makeagif.com/media/1-12-2016/Cv_-WL.gif

Revision as of 16:07, 12 January 2016

The is the "Processing im Park" page of Jason Langheim.

Homework 1

Our first Homework was to create a slideshow of previously taken pictures. My topic was branches and this is my code:

PImage[] images = new PImage[9];

void setup() {
  size(300, 300);
  frameRate(5);
  for (int i = 0 ; i < images.length; i++)
  { 
    images [i] = loadImage("b" + nf(i+1, 2) + ".JPG");
  }
} 
void draw()
{
  int counter = frameCount % 9;
  image(images[counter], 0, 0, 300, 300);
}

which resulted in this:

pAZ-YO.gif

Homework 2

In this homework we were supposed to do a collage. Mine was in the style of david hockney.

PImage[] images = new PImage[25];      // Array für Bildvariablen erstellt
PImage[] parts = new PImage[25];      //  Array für die Teile der Bilder erstellt
int x;
int y;

void setup() {
  size(500, 500);
  for (int i = 0 ; i < images.length; i++)
  { 
    images [i] = loadImage("b" + (i+1) + ".JPG");
  }
  for (int o=0 ; o < parts.length; o++)
 {
  images [o].resize(width,height); 
  image(images [o], 0, 0, 500, 500);
  x = (o % 5) * 100;
  y = (o / 5) * 100;
  parts[o] = get(x,y,100,100);            //Aus jedem Bild wird nur der Teil entnommen der benötigt wird
 }
  
}
void draw() {
  background(0);
  for (int i = 0; i < parts.length; i++){
    int x = (i % 5) * 100;
    int y = (i / 5) * 100;

  image(parts[i], x, y, 100, 100);        //Zusammensetzung aller Teile aus den verschiedenen Bildern zu einem Bild
  }
  for( int p = 0; p < 4;p++){
  rect((p*100)+98, 0, 4, 500);
  rect(0, (p*100)+98 , 500, 4);
  noStroke();
  }
  saveFrame("hockney.JPG");
}

the result:

Hockney.JPG

Homework 3

PImage[] images = new PImage[19];
PImage alpha;

int w=100;
int h;

void setup() {
  size(400, 500);
  frameRate(10);
  background(255);
  for (int i = 0 ; i < images.length; i++)
  { 
    images [i] = loadImage("IMG_0" + (701 + i) + ".JPG");
    alpha = loadImage("alphamask.gif");
    images [i].mask(alpha);
    images [i].resize(100, 100);
    println(i);
  }
  
  
} 
void draw()
{
  if(mousePressed){
     int counter = frameCount % 19;
  image(images[counter], mouseX - 50, mouseY - 50);
  }
}


Cv_-WL.gif