kroko
YaBB Newbies
Offline
Posts: 7
Load sketches based on presentation time
Dec 17th , 2008, 6:31pm
Hello! I'm quite new to processing, previously played with quartz composer. I stumbled upon a problem that qc struggles to work with multiple webcams instantly. Therefore tried to code my concept into processing and with success!; seems I won't even go back :) The question: I have multiple (in the endproject presumably 5) sketches. The representation could be: // sketch 1 void setup() { // hundreds of lines size(200,200); frameRate(30); } void draw() { // hundreds of lines background(255,0,0); } // sketch 2 void setup() { size(200,200); frameRate(30); } void draw() { background(0,100,0); } // sketch 3 void setup() { size(200,200); frameRate(30); } void draw() { background(0,0,255); } Basically n totaly independent compositions, each displaying different things (not just changing bg colour :)), each one using different libraries etc. Is processing able to load sketches dynamically based on some rule? What I need is for the compositions to change every n minutes and/or when speciffic data has changed in mysql. Of course, I could merge all the code in one file, but then it will become messy. I'd simply like to keep every sketch independent, so they would be more easily to manage etc etc. The pseudoscript could be // a "mastersketch" to load and display other sketches global - define paths to sketches, maybe set up some rules for each void setup() { //setup } void draw() { //Loading and drawing other sketches, based on some rules, whatever they are (time, iteration position, rule that's read from mysql etc). //based on time, a fast implementation ;) loads 3 sketches, each one shown for 20 seconds if (second() >= 0 && second() < 20) { loadsketch[1]; } else if (second() >= 20 && second() < 40) { loadsketch[2]; } else { loadsketch[3]; } } Maybe there's other way to achieve this? Many thanks in advance, kroko