/* * babe@rockitbaby.de * * this code is very quick'n'dirty * but does it's job */ import processing.video.*; Movie m; //MovieMaker mm; float mMin = 0.3; //0.3; //68; float mMax = 3.0; //2.2; //95; int scanX = 0; float pos = 0.1; int lastY; int mode = 0; int[] p; PImage chart; void setup() { size(480, 360); p = new int[width]; String img = "chart-4.png"; chart = loadImage(img); image(chart, 0, 0, 480, 360); frameRate(30); m = new Movie(this, "ackermann.mov"); m.loop(); lastY = 0; //mm = new MovieMaker(this, width, height, "mm.mov", // 30, MovieMaker.H263, MovieMaker.HIGH); } void draw() { if (mode == 0) { movietime(); } else { fadeOut(); } //mm.addFrame(); } void keyPressed() { if (key == ' ') { //mm.finish(); // Finish the movie if space bar is pressed! } } void fadeOut() { fill(0, 0, 0, 1); rect(0, 0, width, height); fill(255, 0, 0); for(int i = 0; i < scanX; i++) { if (p[i] != 0) { rect(i, p[i], 6, 6); //rect(i, p[i], 4, 4); } } } void movietime() { background(0); image(chart, -50, 0, 550, 360); loadPixels(); int y = 0; int ii = 0; for (int i = scanX; i < (width * height); i = i + width) { ii++; if (red(pixels[i]) > 200 && blue(pixels[i]) < 100) { y = ii; //continue; pixels[i] = color(255, 255, 255); pixels[i - 1] = color(255, 255, 255); pixels[i + 1] = color(255, 255, 255); } else { pixels[i] = color(0); } } p[scanX] = y; updatePixels(); if (scanX < width - 1) { scanX += 1; } else { mode = 1; //scanX = 0; } //println(frameRate); y = height - y; if (y != height && y != lastY) { pos = map(y, 0, height, mMin, mMax); println(str(scanX) + " : " + str(y) + " : " + str(pos) + " : " + frameRate); lastY = y; } if(m.available()) { //m.jump(pos); m.speed(pos); m.read(); //image(m, 0, 0, 300, 225); image(m, 0, 0); } noStroke(); fill(255, 0, 0, 95); for(int i = 0; i < scanX; i++) { if (p[i] != 0) { rect(i, p[i], 6, 6); //rect(i, p[i], 4, 4); } } /* loadPixels(); print(red(pixels[mouseX * mouseY])); print(' '); print(green(pixels[mouseX * mouseY])); print(' '); println(blue(pixels[mouseX * mouseY])); */ }