Recitation 10: Workshops by You Xu (Ian)

During week’s recitation, we first reviewed the basics about mapping function. It refreshed my mind, and I also applied the map function in my later exercise.

Among all the three workshops, I chose to attend the media manipulation workshop since I think I will need to use some dynamic image and video in my final project, and I am already very familiar with serial communication and OOP during my previous computer sciences courses.

During the workshop, I learned many new built-in functions related to image, video, caption, and pixels. They are all listed in the slides. Therefore, I tried to apply them to a very simple exercise. I chose my favorite short online video on Vimeo: Watchtower of Turkey by Leonardo Dalessandri.

Since I learned how to start, pause, and loop the video, I tried to use my mouse input to control the playing of the video. Moreover, I also tried to move the video screen around the canvas by using my mouse as well. These functions are amazing. I applied the map function to the position of the mouse as well to make sure the video will not go outside the canvas.

I believe it will be helpful to my final project when coding the dynamic user interface.

Work Cited

Dalessandri, Leonardo. Watchtower of Turkey.

Code:

import processing.video.*;
Movie movie1;
void setup(){
  size(640, 640);
  movie1 = new Movie(this, "01.mp4");
  movie1.play();
}
void draw(){
  colorMode(HSB);
  float c = map(mouseX+mouseY, 0, 1280, 0, 255);
  background(c, 120, 255);
  if (movie1.available()){
    movie1.read();
  }
  if(mousePressed){
    movie1.pause();
  }else{
    movie1.play();
  }
  float x = map(mouseX, 0, 640, 0, 640-480);
  float y = map(mouseY, 0, 640, 0, 640-270);
  image(movie1, x, y);
}

Leave a Reply