//week15_01_multiple windows
// File > Examples > Demos > Tests > MultipleWindows
void setup(){
size(200, 200);
background(255, 0, 0);
WindowB child = new WindowB();
}
void draw(){
}
class WindowB extends PApplet {
public WindowB(){
super();
PApplet.runSketch(new String[]{this.getClass().getName()}, this);
}
public void settings(){
size(300, 200);
}
public void setup(){
background(0, 255, 0);
}
public void draw(){
}
}
// week15_02_multiple_window_PGraphics
PGraphics pg;
void setup(){
size(400, 400, P3D);
pg = createGraphics(200, 200, P3D);
}
void draw(){
background(255, 0, 0);
pg.beginDraw();
pg.background(0, 255, 0);
pg.translate(100, 100);
pg.rotateY(radians(frameCount));
pg.box(100);
pg.endDraw();
image(pg, 0, 0);
}
// week15_03_multiple_window_PGraphics
PGraphics pg1,pg2,pg3,pg4;
void setup(){
size(400, 400, P3D);
pg1 = createGraphics(200, 200, P3D);
pg2 = createGraphics(200, 200, P3D);
pg3 = createGraphics(200, 200, P3D);
pg4 = createGraphics(200, 200, P3D);
}
void draw(){
background(255, 0, 0);
pg1.beginDraw();
pg1.background(0, 255, 0);
pg1.translate(100, 100);
pg1.rotateY(radians(frameCount));
pg1.box(100);
pg1.endDraw();
pg2.beginDraw();
pg2.background(255, 0, 0);
pg2.translate(100, 100);
pg2.rotateY(radians(frameCount));
pg2.box(100);
pg2.endDraw();
pg3.beginDraw();
pg3.background(0, 0, 255);
pg3.translate(100, 100);
pg3.rotateY(radians(frameCount));
pg3.box(100);
pg3.endDraw();
pg4.beginDraw();
pg4.background(255, 0, 255);
pg4.translate(100, 100);
pg4.rotateY(radians(frameCount));
pg4.box(100);
pg4.endDraw();
image(pg1, 0, 0);
image(pg2, 200, 0);
image(pg3, 0, 200);
image(pg4, 200, 200);
}
// week15_04_multiple_window_PGraphics
PGraphics pg1,pg2,pg3,pg4;
Arcball arcball;
void setup(){
size(400, 400, P3D);
arcball = new Arcball(this, 200);
pg1 = createGraphics(200, 200, P3D);
pg2 = createGraphics(200, 200, P3D);
pg3 = createGraphics(200, 200, P3D);
pg4 = createGraphics(200, 200, P3D);
}
void mousePressed(){
arcball.mousePresses();
}
void mouseDragged(){
arcball.mouseDragged();
}
void draw(){
background(255, 0, 0);
pg1.beginDraw();
pg1.background(0, 255, 0);
arcball.run();
//pg1.translate(100, 100);
//pg1.rotateY(radians(frameCount));
pg1.box(100);
pg1.endDraw();
pg2.beginDraw();
pg2.background(255, 0, 0);
pg2.translate(100, 100);
pg2.rotateY(radians(frameCount));
pg2.box(100);
pg2.endDraw();
pg3.beginDraw();
pg3.background(0, 0, 255);
pg3.translate(100, 100);
pg3.rotateY(radians(frameCount));
pg3.box(100);
pg3.endDraw();
pg4.beginDraw();
pg4.background(255, 0, 255);
pg4.translate(100, 100);
pg4.rotateY(radians(frameCount));
pg4.box(100);
pg4.endDraw();
image(pg1, 0, 0);
image(pg2, 200, 0);
image(pg3, 0, 200);
image(pg4, 200, 200);
}
沒有留言:
張貼留言