Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import processing.video.*;
- int x, y;
- float angle, d;
- PVector[] v = new PVector[25];
- Movie movie;
- void setup() {
- size(480, 360);
- //movie = new Movie(this, "bowie.mp4");
- movie = new Movie(this, "pokerface.mp4");
- //movie = new Movie(this, "canned.mp4");
- //size(640, 360);
- //movie = new Movie(this, "automaton.mp4");
- //movie = new Movie(this, "holdup.mp4");
- //size(854, 480);
- //movie = new Movie(this, "bunny.mov");
- //size(1280, 720);
- //movie = new Movie(this, "beyonce.mp4");
- background(0);
- movie.play();
- initWalkers();
- }
- void movieEvent(Movie movie) {
- movie.read();
- }
- void draw() {
- if (frameCount>5) {
- //distort(); // holdup
- //paintLines(); // automaton
- paintStripes(); // bowie
- //squares(); // pokerface
- //slitScan(); // bunny
- //centerColorDots(); // bowie
- //walkers(); // bunnie.mov
- //if (frameCount%5==0) carousel(); // canned
- }
- //saveFrame("image-####.png");
- }
- void distort() {
- // video = series of images so can be treated like images
- background(0);
- //tint(255,150);
- image(movie, 0, 0, mouseX, mouseY);
- }
- void paintLines() {
- // get color from the center of the image
- color c = movie.get(movie.width/2, movie.height/2);
- stroke(c);
- // draw line
- line(x, 0, x, height);
- //line(0,y,width,y);
- //line(x, y, width-x, height-y);
- // move line
- x++;
- //y++;
- if (x>width) {
- x = 0;
- }
- /*
- if (y>height) {
- y = 0;
- }
- */
- // display small movie in upper left corner
- copy(movie, 0, 0, width, height, 0, 0, width/6, height/6);
- }
- void paintStripes() {
- // max height of the stripe
- int h = height/3;
- // get color from the center of the image
- color c = movie.get(width/2, height/2);
- stroke(c);
- // map the brightness of the pixel to the height of the rectangle
- float br = brightness(c);
- float sz = map(br, 0, 255, 30, h);
- // draw line
- rectMode(CENTER);
- rect(x, y, 1, sz);
- // move x and y
- x++;
- if (x>width) {
- x = 0;
- y = y + h/2;
- if (y>height) y = 0;
- }
- // display small movie in upper left corner
- copy(movie, 0, 0, width, height, 0, 0, width/6, height/6);
- }
- void squares() {
- // get the color from the center of the image
- color c = movie.get(width/2, height/2);
- fill(c);
- //noStroke();
- // size of the squares
- int sz = 10;
- rect(x, y, sz, sz);
- // move to the start of the next square
- x = x + sz;
- // if the squares have reached the right border, jump to the next row
- if (x > width) {
- x = 0;
- y += sz;
- // if the squares have reached the bottom right corner, jump to the top left corner again
- if (y > height) {
- y = 0;
- }
- }
- // display small movie in upper left corner
- copy(movie, 0, 0, width, height, 0, 0, width/6, height/6);
- }
- void slitScan() {
- // copy one horizontal line from the image and display it
- copy(movie, 0, y, width, 1, 0, y, width, 1);
- // move down one row
- y = y + 1;
- // if at the bottom then restart at the top
- if (y>height) {
- y = 0;
- }
- // display small movie in upper left corner
- copy(movie, 0, 0, width, height, 0, 0, width/6, height/6);
- }
- void centerColorDots() {
- color c = movie.get(width/2, height/2);
- fill(c, 150);
- noStroke();
- //line(x, 0, x, height);
- float br = brightness(c);
- float y = map(br, 0, 255, height, 0);
- //point(x,y);
- rect(x, y, random(20, 50), 5, 5);
- x++;
- if (x>width) x = 0;
- copy(movie, 0, 0, width, height, 0, 0, width/6, height/6);
- }
- void walkers() {
- float r = 5;
- float sz = 2;
- for (int i=0; i<v.length; i++) {
- v[i].x += random(-r, r);
- v[i].y += random(-r, r);
- color c = movie.get(int(v[i].x), int(v[i].y));
- noStroke();
- fill(c, 150);
- ellipse(v[i].x, v[i].y, sz, sz);
- if (v[i].x > width || v[i].x < 0) v[i].x = width/2;
- if (v[i].y > height || v[i].y < 0) v[i].y = height/2;
- }
- // display small movie in upper left corner
- copy(movie, 0, 0, width, height, 0, 0, width/6, height/6);
- }
- void walkers2() {
- for (int i=0; i<1; i++) {
- float x = random(width);
- float y = random(height);
- int sz = (int) random(20,200);
- PImage tmp = movie.get(int(x),int(y), sz,sz);
- tint(255, random(10,150));
- image(tmp, int(x), int(y));
- }
- // display small movie in upper left corner
- copy(movie, 0, 0, width, height, 0, 0, width/6, height/6);
- }
- void initWalkers() {
- for (int i=0; i<v.length; i++) {
- v[i] = new PVector(width/2, height/2);
- }
- }
- void carousel() {
- PImage tmp = movie.get();
- tmp.resize(width/5, height/5);
- tint(255, 150);
- pushMatrix();
- translate(width/2, height/2);
- rotate(angle);
- imageMode(CENTER);
- image(tmp, d, 0);
- popMatrix();
- angle += radians(5);
- d += 1;
- if (d>width*.7) {
- d = 0;
- angle = 0;
- }
- copy(movie, 0, 0, width, height, 0, 0, width/6, height/6);
- //filter(GRAY);
- }
- void keyPressed() {
- saveFrame("image-###.png");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement