does setup and draw function run parallel in processing
No. First the setup()
function is called and completes, then the draw()
function is called 60 times per second.
does the fileselected function completes its execution even before while loop execution.
The fileSelected()
function will be called when the user selects a file. You really shouldn't call the delay()
function in a loop like that.
How do I make the draw function to wait until it receives the necessary arguments to run.
Something like this:
boolean fileLoaded = false;
void setup(){
size(800, 600);
selectInput("Select a file to process:", "fileSelected");
}
void fileSelected(File selection){
fileLoaded = true;
}
void draw(){
if(!fileLoaded){
//short-circuit and stop the function
return;
}
}
You could go a step further and use the noLoop()
and loop()
functions. More info can be found in the reference.