glich movie

画像

processingでquicktime movie読み込んでglich。image(xpos, ypos, width, height)の値をランダムにして背景消さないだけでもそれっぽいのはできるけど、そこからarraycopy使ってランダムな長さ分だけbufferに入れて、ランダムな位置に表示するとさらにメッタメタのギッタギタにできる。落ち着いて計算して、もうちょっと色々試す。

import processing.video.*;
Movie video;

int movieWidth = 160;
int movieHeight = 120;
int buffer[];
int moviePixels;
int srcPos;
int dstPos;
int bufferIndex;
int copyLength;
void setup() {
  size(400, 200);
  // also try with other video sizes
  video = new Movie(this, "station.mov");
  video.loop();
  moviePixels = movieWidth * movieHeight;
  buffer = new int[width*height];
  background(0);
  frameRate(24);
}

void draw() {
  srcPos = int(random(moviePixels));
  dstPos = int(random(width*height));

  copyLength = width*height-dstPos;
  
  video.read();
  image(video, int(random(width)), int(random(height)), int(random(width)), int(random(height)));
  
  loadPixels();
  arraycopy(pixels, srcPos, buffer, 0, int(random(moviePixels)));
  arraycopy(buffer, 0, pixels, dstPos, copyLength);

  updatePixels();
  if(keyPressed==true) {
    saveFrame();
  }
}