Skip to content

Instantly share code, notes, and snippets.

@edmorais
Last active May 25, 2016 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edmorais/553a5b91a48b746ef8e55400c034d835 to your computer and use it in GitHub Desktop.
Save edmorais/553a5b91a48b746ef8e55400c034d835 to your computer and use it in GitHub Desktop.
Exemplo de sketch com duas janelas, com passagem de variáveis.
/*_ ___ ___ ___ __ _ __
| | / __|_ _|_ ) \/ |/ /
| |__\__ \| | / / () | / _ \
|____|___/___/___\__/|_\___/
Aula de 23/05/2016:
Exemplo de sketch com duas janelas, com passagem de variáveis.
Por Eduardo Morais / FBAUP - www.eduardomorais.pt/fbaup/
*/
// Variaveis globais comuns a ambas as janelas:
int x, y;
/*
Função setup() da janela principal:
*/
void setup() {
size(100, 100);
String[] args = {"YourSketchNameHere"};
SecondApplet sa = new SecondApplet();
PApplet.runSketch(args, sa);
}
/*
Função draw() da janela principal:
*/
void draw() {
background(0);
ellipse(mouseX, mouseY, 10, 10);
x = mouseX;
y = mouseY;
}
/*
Classe da segunda janela!
Aqui dentro terá o seu próprio settings(), setup() e draw()!
*/
public class SecondApplet extends PApplet {
/*
Função settings() da janela secundária:
*/
public void settings() {
size(200, 100);
}
/*
Função draw() da janela secundária:
*/
public void draw() {
background(255);
fill(0);
ellipse(100, 50, x, y);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment