/** * Loop. * Built-in video library replaced with gsvideo by Andres Colubri * * Move the cursor across the screen to draw. * Shows how to load and play a QuickTime movie file. */ import fullscreen.*; import processing.serial.*; import cc.arduino.*; import codeanticode.gsvideo.*; PImage black; PImage Red; int flag=0; int time=0; int AL=0; GSMovie myMovie; GSMovie myMovie1; GSMovie myMovie2; GSMovie myMovie3; GSMovie myMovie4; Arduino arduino; FullScreen fs; void setup() { size(540, 320,P2D); // 5 fps frameRate(5); // Create the fullscreen object fs = new FullScreen(this); // enter fullscreen mode fs.enter(); background(0); // Load and play the video in a loop arduino = new Arduino(this, Arduino.list()[0], 115200); myMovie = new GSMovie(this, "Back5.mov"); // myMovie1 = new GSMovie(this, "sensing_red.mov"); myMovie2 = new GSMovie(this, "B.mov"); myMovie3 = new GSMovie(this, "A_1.mov"); // myMovie4 = new GSMovie(this, "B_1.mov"); black=loadImage("black.jpg"); Red=loadImage("red.jpg"); myMovie.loop(); // myMovie1.loop(); myMovie2.loop(); myMovie3.loop(); // myMovie4.loop(); } void movieEvent(GSMovie myMovie) { myMovie.read(); // myMovie1.read(); } void back(){ tint(255,255); image(myMovie,0,0,540,320); // blend(myMovie,0,0,540,320,0,0,540,320,BURN); } int valueMap(int value, int in_min, int in_max, int out_min, int out_max) { return (value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } void draw() { int dstSensor1 = arduino.analogRead(5); int dstSensor2 = arduino.analogRead(3); int dstSensor3 = arduino.analogRead(1); dstSensor1 = valueMap(dstSensor1, 0, 1023, 0, 255); dstSensor2 = valueMap(dstSensor2, 0, 1023, 0, 255); dstSensor3 = valueMap(dstSensor3, 0, 1023, 0, 255); print(dstSensor2 + " "); back(); if(dstSensor1 > 100 && dstSensor1 < 120 ) { tint(255,50); image(myMovie2,0, 0,540,320); } if(dstSensor2 > 100 && dstSensor2 < 120 ) { tint(255,50); image(myMovie3,0, 0,540,320); } /* if(flag==0){ tint(255,50); image(myMovie1,0,0,540,320); // myMovie1.mask(myMovie1); // tint(255,50); image(myMovie2,0, 0,540,320); rotate(PI); // tint(255,50); image(myMovie3,-540, -320,540,320); } else{ tint(255,50); image(Red,0,0,540,320); for(int i=0; i<2; i++) image(black,0,0,540,320); } */ if(time==180){ tick1(); } if(time==220){ tick2(); time=0; } time++; } void tick1(){ flag=1; } void tick2(){ flag=0; // myMovie1.jump(0); myMovie2.jump(0); myMovie3.jump(0); // myMovie4.jump(0); } /* void clock(){ if(time==100){ tick(); time=0; } else time++; }*/