multiple windows
in
Programming Questions
•
2 years ago
Hi All,
I am using multiple windows in a setup similar to this:
This works great except that i have many different classes that need to draw to either window depending on the context. A class may have a draw function that looks like this:
What is the best way to configure this draw method and that of polygon so that I can pass them an argument that tells them which PApplet to draw to (s or the default)?
Thanks for your thoughts,
Francis
I am using multiple windows in a setup similar to this:
PFrame f;
secondApplet s;
void setup() {
size(320, 240);
PFrame f = new PFrame();
}
void draw() {
background(255,0,0);
fill(255);
rect(10,10,frameCount%100,10);
s.background(0, 0, 255);
s.fill(100);
s.rect(10,20,frameCount%120,10);
s.redraw();
}
public class PFrame extends Frame {
public PFrame() {
setBounds(100,100,400,300);
s = new secondApplet();
add(s);
s.init();
show();
}
}
public class secondApplet extends PApplet {
public void setup() {
size(400, 300);
noLoop();
}
public void draw() {
}
}
- void draw() {
polygon p;
for (int i = 0; i < _polygons.size(); i++) {
p = (polygon) _polygons.get(i);
p.draw();
}
fill(0);
stroke(0);
ellipse(0.5*width, 0.06*height, (0.04*2)*width, (0.04*2)*height);
}
What is the best way to configure this draw method and that of polygon so that I can pass them an argument that tells them which PApplet to draw to (s or the default)?
Thanks for your thoughts,
Francis
1