GMU:Processing im Park/Emilio Aguas/sample code test03

From Medien Wiki

--- Processing3.0 Code---

taking pixels and display it

//Movie library
import processing.video.*;

//Declare movie array
Movie [] allMovies= new Movie[4];


void setup() {
  //Keep the aspect ratio 16:9
  size(800, 450);
  //Max values for hue, sturation, brightness and alpha
  colorMode(HSB, 360, 100, 100, 100);
  background(50, 75, 93);
  //Fill the movie array
  for (int i= 0; i < allMovies.length; i++) {
    allMovies[i]= new Movie(this, "Ilm_vid0"+(i+1)+".m4v");
    allMovies[i].loop();
  }
}

void draw() {
  int tamX= width/2;
  int tamY= height/2;
  float sat =map(mouseX, 0, width, 0, 100);
  // Display all the movies at the same time in different positions
  for (int i= 0; i < allMovies.length; i++) {
    int posX= (i % 2) * tamX;
    int posY= (i / 2) * tamY;
    //dispalying videos changing saturation
    tint(130, sat/2, 100, 10);
    image (allMovies[i], posX, posY, tamX, tamY);
  }
  loadPixels();
  // move along the position of every single pixel
  for (int x=0; x<width; x++) {
    for (int y=0; y<height; y++) {
      //data location of the pixels in one value
      int loc= x+(y*width);
      //green display of the even pixels
      if (x % 2 ==0) {
        pixels[loc] =color (130, 45, 100);
      }
    }
  }
  updatePixels();
}

void movieEvent(Movie Ilm) {
  Ilm.read();
}