Recitation 10-Media Manipulation(Xinran Fan)

Recitation 

First I decide to begin with image which I think maybe a little bit easy, I firstly try to use blend. I download two pictures from internet, however, the code can not run for the size is not fitted, at the first I think is the size of the background picture and the former one and waste of a lot of time on it. Thank to an assistant, I find out it is the size of the canvas and the picture. However, the picture I choose is not so suit for such function which looks kind of blink.

PImage pollution = loadImage("pollution.jpg");
PImage turtle = loadImage("turtle.jpg");
size(1000,600);
pollution.resize(1000, 600);
turtle.resize(600, 600);
background(pollution);
//image(turtle,0,0);
blend(turtle, 200, 0, 500, 600,333, 0,300, 600, LIGHTEST);

Then I make a video including Pixels, audio and video;

import processing.sound.*;
import processing.video.*;
Movie myMovie;
SoundFile sound;
void setup() {
  size(480, 480);
   myMovie = new Movie(this, "ocean.mp4");
  sound = new SoundFile(this, "ocean.wav");
//define the state of the video
 myMovie.loop();
  sound.loop();
}
void draw() {
 
  myMovie.loop();
  if (myMovie.available()) {
    myMovie.read();
    myMovie.loadPixels();
//read the current frame of my video
int circleSize = 15;
  int w = myMovie.width;
  int h =myMovie.height;
  for (int y = 0; y < h; y+=circleSize){
    for (int x = 0; x < w; x+=circleSize) {
      int i =  x + y*w;
      fill( myMovie.pixels[i] );
      ellipse(x,y,circleSize,circleSize);
    }

  }
 
    myMovie.updatePixels();
//draw the current frame of the video
}

}

Leave a Reply