gpt4 book ai didi

image - 在“处理”中为单个草图创建多个窗口

转载 作者:行者123 更新时间:2023-12-04 13:32:27 25 4
gpt4 key购买 nike

如何在“处理”中创建单个草图的多个窗口?

实际上,我想在一个窗口中检测并跟踪特定颜色(通过网络摄像头),并将检测到的坐标显示为另一个窗口中的点,直到现在,我仍可以在检测到该颜色的同一个窗口中显示这些点。我想将其拆分为两个不同的窗口。

最佳答案

您需要创建一个新框架和一个新的PApplet ...这是一个示例草图:

import javax.swing.*; 
SecondApplet s;
void setup() {
size(640, 480);
PFrame f = new PFrame(width, height);
frame.setTitle("first window");
f.setTitle("second 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();
add(s);
s.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;
}
}

关于image - 在“处理”中为单个草图创建多个窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20730901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com