We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello folks!
Again here with a Processing - Python Mode question. I'm trying to rewrite the code at this link using python syntax, but I'm getting some errors.
Can some of you give me an hint?
here is the python code:
import javax.swing
s = SecondApplet()
def setup():
size(640, 480)
f = PFrame (width, height)
frame.setTitle("first window")
f.setTitle("second window")
fill(0)
def draw():
background(255)
ellipse(mouseX, mouseY, 10, 10)
s.setGhostCursor(mouseX, mouseY)
class PFrame (JFrame):
def __init__(self, width, height):
setBounds(100, 100, width, height)
s = SecondApplet()
add(s)
s.init()
show()
class SecondApplet(PApplet):
def __init__(self, ghostX, ghostY):
def setup():
background(0)
noStroke()
def draw():
background(50)
fill(255)
ellipse(mouseX, mouseY, 10, 10)
fill(0)
ellipse(ghostX, ghostY, 10, 10)
def setGhostCursor(ghostX, ghostY):
self.ghostX = ghostX
self.ghostY = ghostY
and here is the original Processing sketch found at the link above:
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;
}
}
Answers
Anyone? :)