We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi
I noticed that having a p5.js sketch running in my browser is taxing CPU load, even if the sketch in a tab that is not showing.
how would you do to have the sketch going noLoop() when not in focused and resume loop() when focused is back ?
is there a resumeFocus() event function in p5.js ?
would it be a good id to catch the last frame into an image and display it while out of focuse ?
Answers
I would add your own
isPaused
variable. That way you have a way to grab a frame to use, and an easy way to resume when focused again:Untested code, YMMV.
https://Forum.Processing.org/two/discussions/tagged?Tag=onblur()
it works like a charm @TfGuy44, thank you
even added a blur to make it nicer ^^
and thank you @GoToLoop for being willing to help ... even though you answers are getting closer and closer to a "why don't you google it ?" kind of answer ;)