-
What even IS this/?/1!?1?
So you know how video games (like Minecraft!!1!) resize the window to ‘fullscreen’ when you pressF11
? This does that. Setting the window to “undecorated” means to remove the title bar, the window maximize, window minimize, and window close buttons. -
How did you do it,
("o_O))
?
Right: here is an explanation as to how this works:
Basically, thewindow.setUndecorated()
method runs a new thread. If you continue to usedraw()
, you are rendering graphics to the screen, which disrupts, orinterrupts
that thread.
To avoid that, I simply put awhile
loop to wait till the thread is done.
Theif
exists to check if the window was already set to undecorated, and if it needs to be done again, since it takes a bit of time to set the window as undecorated! -
Why do I set the window to invisible and then visible?
Because for some reason, it resizes it perfectly to fit the screen, and also makes the taskbar disappear. It is needed even though there is asurface.setLocation(0, 0);
-
Why am I using a method called ‘
post()
’ and what is it?!
Processing “handles” thedraw()
function inside a function calledhandleDraw()
, which runs every frame. However, to ensure that thedraw()
function is ‘safe’ to use (so you didn’t change things and cause random errors all the time), the Processing development team made sure that you couldn’t access them. Problem: libraries need this functionality, and so do we! So they allowed it to be extended and made two more methods, calledpre()
andpost()
, which are called before and afterdraw()
is executed, respectively. -
Why so many
if
s?!
If you’ve ran this code, you know how long it takes to do the task! Theif
s ensure that the task isn’t done every single frame - it’s an optimization. But the solution as a whole isn’t as optimized.
I’ll post the ‘optimized’ version of the code soon!
Check the solution answer here, ":D! -
What’s this “
window
” object?!
This is a way to dig into Processing’s workings and do some of this stuff. I myself came to know about it from here, months ago: Get location of a PApplet window - #10 by micycle
To know what it contains, check the solution answer here
1 Like