Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (43 sloc) 1.23 KB
/*
Sine Glasses
Author: Bhavna Mahadevan
Code Snippet - Fall 2010
*/
// Global variables for movie playback
import processing.video.*;
Movie myMovie;
float i=1.0;
int T=30*5,f=0;
float mul = -.1;
// setup is called once
void setup() {
size(1280, 720, P2D); // Create applet of correct size, use fast 2D renderer
myMovie = new Movie(this, "Movie_Geometric.mp4",3); // Access the movie
myMovie.loop(); // makes movie loop
noLoop(); // makes it so draw only gets called on redraw()
}
// This function is called every time there is a new frame ready
// In it, we will create the output image from the movie frame, then call redraw.
void movieEvent(Movie m) {
// read the frame
m.read();
i+=mul;
if (i<=0) {mul*=-1; i+=mul;}
else if (i>=1) mul*=-1;
for (int x = 0; x < 1280; x++)
for (int y = 0; y < 720; y++ )
set(x, y, getSourcePixel(x,y,myMovie));
// now redraw the output image
redraw();
}
// This code does not change, it just draws the output image automatically
void draw() {
}
// Calculate the source pixel coordinates and look up the color
color getSourcePixel(int x, int y, PImage inputImage)
{
int s = x;
float new_y= y+i*50*sin(x*0.02);
int t = (int) new_y;
return inputImage.get(s,t);
}
You can’t perform that action at this time.