티스토리 뷰
한번 5개의 processing 창을 동시에 출력하는 예제를 해봤다. 내용은 각 창마다 마우스 포인터의 위치를 따라가는 예제이다.
import javax.swing.*;
SecondApplet s;
ThirdApplet t;
FourthApplet f;
FifthApplet ff;
void setup() {
size(640, 480);
PFrame f = new PFrame(width, height);
PFrame s = new PFrame(width, height);
PFrame t = new PFrame(width, height);
PFrame ff = new PFrame(width, height);
frame.setTitle("first window");
f.setTitle("second window");
s.setTitle("third window");
t.setTitle("fourth window");
ff.setTitle("fifth window");
fill(0);
}
void draw() {
background(255);
ellipse(mouseX, mouseY, 10, 10);
s.setGhostCursor(mouseX, mouseY);
}
public class PFrame extends JFrame {
public PFrame(int width, int height) {
setBounds(100, 100, width, height);
s = new SecondApplet();
t = new ThirdApplet();
f = new FourthApplet();
ff = new FifthApplet();
add(s);
add(t);
add(f);
add(ff);
s.init();
t.init();
f.init();
ff.init();
show();
}
}
public class SecondApplet extends PApplet {
int ghostX, ghostY;
public void setup() {
background(0);
noStroke();
}
public void draw() {
background(50);
fill(255);
ellipse(mouseX, mouseY, 10, 10);
fill(0);
ellipse(ghostX, ghostY, 10, 10);
}
public void setGhostCursor(int ghostX, int ghostY) {
this.ghostX = ghostX;
this.ghostY = ghostY;
}
}
public class ThirdApplet extends PApplet {
int ghostX, ghostY;
public void setup() {
background(0);
noStroke();
}
public void draw() {
background(50);
fill(255);
ellipse(mouseX, mouseY, 10, 10);
fill(0);
ellipse(ghostX, ghostY, 10, 10);
}
public void setGhostCursor(int ghostX, int ghostY) {
this.ghostX = ghostX;
this.ghostY = ghostY;
}
}
public class FourthApplet extends PApplet {
int ghostX, ghostY;
public void setup() {
background(0);
noStroke();
}
public void draw() {
background(50);
fill(255);
ellipse(mouseX, mouseY, 10, 10);
fill(0);
ellipse(ghostX, ghostY, 10, 10);
}
public void setGhostCursor(int ghostX, int ghostY) {
this.ghostX = ghostX;
this.ghostY = ghostY;
}
}
public class FifthApplet extends PApplet {
int ghostX, ghostY;
public void setup() {
background(0);
noStroke();
}
public void draw() {
background(50);
fill(255);
ellipse(mouseX, mouseY, 10, 10);
fill(0);
ellipse(ghostX, ghostY, 10, 10);
}
public void setGhostCursor(int ghostX, int ghostY) {
this.ghostX = ghostX;
this.ghostY = ghostY;
}
}
실행 결과는 다음과 같다.
아 참 JFrame의 extend한 PFrame을 여러 형태로 만들어 놓으면 각창의 시작 위치도 조절할 수 있을 법하다. 이건 피곤해서 다음에 해봐야 겠다.
'Processing' 카테고리의 다른 글
[Processing] Basic of Drawing (2) (0) | 2014.02.11 |
---|---|
[Processing] Basic of Drawing (1) (0) | 2014.02.07 |
[kinect with processing] kick with point Cloud (12) | 2013.07.14 |
[kinect with processing] 3D Button in Point Cloud (2) | 2013.07.12 |
[Kinect with Processing] FingerTracker (1) | 2012.12.15 |
[Processing] Multi-Window 출력 (9) | 2012.11.25 |
[Processing] 동영상 재생 (9) | 2012.11.25 |
- Total
- Today
- Yesterday
- DepthStream
- Kinect SDK
- Kinect
- windows 8
- dynamic programming
- Variance
- 딥러닝
- Gan
- reward
- Policy Gradient
- SketchFlow
- ColorStream
- 강화학습
- Expression Blend 4
- ai
- Off-policy
- End-To-End
- Pipeline
- arduino
- 파이썬
- RL
- TensorFlow Lite
- 한빛미디어
- Windows Phone 7
- PowerPoint
- Offline RL
- Distribution
- processing
- bias
- Kinect for windows
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |