Last active
September 16, 2016 17:13
-
-
Save mariuswatz/6572514e4c80836df34e to your computer and use it in GitHub Desktop.
Set display options for Processing window: Disable frame borders, set always-on-top and position on screen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Marius Watz - http://workshop.evolutionzone.com | |
// | |
// Window frame control: Disable frame decoration (see | |
// init() function), manipulate frame position (see | |
// keyPressed(), draw() ) | |
int framePosX=0; | |
int framePosY=0; | |
void setup() { | |
size(400, 400); | |
background(0); | |
} | |
void draw() { | |
// set frame location on startup | |
if (frameCount<10) { | |
frame.setLocation(framePosX, framePosY); | |
} | |
// yellow background | |
background(255,255,0); | |
// draw black rect to create fat yellow border | |
fill(0); | |
noStroke(); | |
rect(5,5, width-10,height-10); | |
fill(255,255,0); | |
textAlign(RIGHT); | |
text("framePosX "+framePosX,width-10,25); | |
text("framePosY "+framePosY,width-10,40); | |
stroke(255); | |
line(50, 50, width-50, height-50); | |
} | |
// override PApplet.init() to allow us to turn off | |
// frame decorations | |
boolean frameDecorated=true; | |
public void init() { | |
frame.dispose(); | |
frame.setUndecorated(frameDecorated); // works. | |
// forces window to float on top | |
//frame.setAlwaysOnTop(true); | |
// call PApplet.init() to take care of usual business | |
super.init(); | |
} | |
// use keys to move frame on screen | |
void keyPressed() { | |
int framePosModX=0, framePosModY=0; | |
if (key=='a') framePosModX-=50; | |
if (key=='d') framePosModX+=50; | |
if (key=='w') framePosModY-=50; | |
if (key=='s') framePosModY+=50; | |
if (abs(framePosModX)>0 || abs(framePosModY)>0) { | |
framePosX+=framePosModX; | |
framePosY+=framePosModY; | |
frame.setLocation(framePosX, framePosY); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment