Created
December 8, 2018 11:06
-
-
Save KrabCode/5ca9698e5f8b141c112123f286a54a2b to your computer and use it in GitHub Desktop.
Movable borderless processing window
This file contains hidden or 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
| import processing.core.PApplet; | |
| import java.awt.*; | |
| public class MainApp extends PApplet { | |
| int surfacePosX = 1250; | |
| int surfacePosY = 500; | |
| Point mouse = new Point(0, 0); | |
| Point pmouse = new Point(0, 0); | |
| public static void main(String[] args) { | |
| PApplet.main("MainApp"); | |
| } | |
| public void settings() { | |
| fullScreen(P3D); | |
| smooth(8); | |
| } | |
| public void setup() { | |
| surface.setSize(500, 500); | |
| surface.setResizable(true); | |
| surface.setLocation(surfacePosX, surfacePosY); | |
| } | |
| public void draw() { | |
| updateSurface(); | |
| background(0); | |
| translate(width / 2, height / 2); | |
| ellipse(0, 0, 20, 20); | |
| } | |
| private void updateSurface() { | |
| pmouse = mouse; | |
| mouse = MouseInfo.getPointerInfo().getLocation(); | |
| if (mousePressed) { | |
| surfacePosX -= (pmouse.x - mouse.x); | |
| surfacePosY -= (pmouse.y - mouse.y); | |
| surface.setLocation(surfacePosX, surfacePosY); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment