Created
November 19, 2015 23:36
-
-
Save atduskgreg/b87893bfd4e3e3d3758c to your computer and use it in GitHub Desktop.
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
PWindow w; | |
void setup() { | |
size(320, 240); | |
w = new PWindow(100, 100, 500, 200); | |
} | |
void draw() { | |
background(255, 0, 0); | |
fill(255); | |
rect(10, 10, frameCount, 10); | |
} | |
void mousePressed(){ | |
println("mousePressed"); | |
} |
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
import processing.awt.*; | |
class PWindow extends PSurfaceAWT { | |
PWindowApp app; | |
PGraphics graphics; | |
int w; | |
int h; | |
PWindow(int x, int y, int w, int h) { | |
super( createGraphics(w,h) ); | |
app = new PWindowApp(); | |
app.setParent(this); | |
initFrame(app); | |
} | |
int getWidth(){ | |
return w; | |
} | |
int getHeight(){ | |
return h; | |
} | |
} | |
class PWindowApp extends PApplet { | |
PWindow parent; | |
void setParent(PWindow _parent){ | |
parent = _parent; | |
} | |
void setup() { | |
size(parent.getWidth(), parent.getHeight()); | |
background(0); | |
//noLoop(); | |
} | |
void draw() { | |
println("PWindowApp.draw()"); | |
} | |
// all mouse, keyboard events work in here as expected | |
// TODO: Could there be an API for defining these from the outside? | |
void mousePressed(){ | |
println("second app mouse pressed"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment