We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Running P5 as a background Task
Page Index Toggle Pages: 1
Running P5 as a background Task (Read 495 times)
Running P5 as a background Task
Feb 17th, 2010, 1:14am
 
Is it possible that an exported sketch can run/going on even it is not
an active window. So it can run as an background task?
For example: if i render a »mandelbrot«, i don't want to keep this window in the front...

Thnx for reading and helping!
Re: Running P5 as a background Task
Reply #1 - Feb 17th, 2010, 1:55am
 
Just give it a try! There is no reason your sketch would stop if the window does not have focus.
Re: Running P5 as a background Task
Reply #2 - Feb 17th, 2010, 2:17am
 
I'm not shure what you really want to do. The frame of the p5 sketch isn't allways on Top, so it can be running in the background anyway...

You only could force the window to allways be active with:
import com.sun.awt.AWTUtilities;
frame.setAlwaysOnTop(true);

If "runing in backgroud" means not being visible, you can change this too:


Code:
import com.sun.awt.AWTUtilities;

boolean visible = true;
int number = 0;

void setup() {
size(200, 200);
//force frame to be on top
//frame.setAlwaysOnTop(true);
}

void draw() {
//do sth in the sketch
background(number*5);
number++;
println(number);
if(number >= 255/5) number = 0;

//toggle boolean
visible = !visible;
//set frame visible/unvisible
frame.setVisible(visible);
delay(1000);
}
Re: Running P5 as a background Task
Reply #3 - Feb 17th, 2010, 8:53am
 
thnx very much - i got an error in reasoning....grrrrrroooooar Smiley
Page Index Toggle Pages: 1