====== Créer une seconde fenêtre ======
===Processing 3 ===
void settings() {
size(200, 400);
//fullScreen(2);
}
void setup() {
PApplet.runSketch(platformNames, new SecondApplet());
}
void draw() {
background(0);
fill(255, 0, 0);
ellipse(width / 2, height / 2, 100, 100);
}
public class SecondApplet extends PApplet {
public void settings() {
size(400, 200);
//fullScreen(1);
}
public void setup() {
surface.setTitle("Titre de ma seconde fenetre");
}
public void draw() {
background(255);
fill(0, 255, 0);
ellipse(width / 2, height / 2, 100, 100);
}
}
===Processing 2 ===
Comment créer une seconde fenêtre et comment interagir avec elle :
Une deuxième méthode issue du [[http://forum.processing.org/two/discussion/7202/controlp5-controlwindow-and-controlp5frame#Item_8| Forum Processing]] :
static final void main(final String[] args) {
final String sketch = Thread.currentThread()
.getStackTrace()[1].getClassName();
main(sketch, args);
final Class[] nested;
try {
nested = Class.forName(sketch).getClasses();
}
catch (final ClassNotFoundException cause) {
throw new RuntimeException(cause);
}
println(nested);
println();
for (int i = 0, ii = max (0, nested.length-2); i != ii; ++i)
try {
main(nested[i].getName(), args);
}
catch (final Exception cause) {
println(nested[i] + " isn't a PApplet or isn't public static!");
}
}
void setup() {
size(600, 400, P2D);
smooth(8);
noLoop();
background((color) random(#000000));
}
public static final class MyFrame extends PApplet {
void setup() {
size(300, 200, JAVA2D);
noLoop();
println("MyFrame");
}
void draw() {
background(0);
}
}
public static final class MyApp extends PApplet {
void setup() {
size(300, 200, JAVA2D);
noLoop();
println("MyApp");
}
void draw() {
background(255);
}
}
{{tag>processing sylvain}}