yeolesquid
YaBB Newbies
Offline
Posts: 6
sketch vs. applet?
May 15th , 2006, 11:54pm
Hello everyone. I am a newcomer to Processing and programming and I am working on my first visualization. I have run into a bit of a quirk. When I try to run the code in the sketch window nothing happens; the play arrow is on but nothing shows. However, when I export the code as a firefox applet, I can open it up and it runs as expected with no problems. In my sketch, I worked out how to make 3 circles spin in a triangle formation. Then I tried to convert the code into an object so that I could easily draw multiple groups with different variables. I believe this is where I might have changed something around, because afterwards it stoped previewing. This is my code: Tri t1, t2, t3; void setup () { size (200,400) ; stroke (255) ; fill (255) ; smooth () ; framerate (60) ; t1 = new Tri (width/2, 350, 10, 5, 0.25); t2 = new Tri (width/2, height/2, 10, 10, 0.3); t3 = new Tri (width/2, 50, 10, 15, 0.35); } void draw () { background (0); t1.update (); t2.update (); t3.update (); t1.display (); t2.display (); t3.display (); } class Tri { float rOne; // ellipse radius float rTwo; // distance from center float theta; int xpos; int ypos; float rot; float rotSpeed; float diam = 0; float dSpeed; Tri (int x, int y, float r, float rtS, float dS) { xpos = x; ypos = y; rOne = r; rotSpeed = rtS; dSpeed = dS; } void update () { rTwo = rOne/(sqrt(3)/2); // set triangle radius based on circle size diam = diam + dSpeed; if (diam > rOne*2) {diam = rOne*2;} theta = radians(rot); rot = rot+rotSpeed%360; } void display () { ellipse (xpos+(cos(theta)*rTwo), ypos+(sin(theta)*rTwo),diam,diam); ellipse (xpos+(cos(theta+(TWO_PI/3))*rTwo), ypos+(sin(theta+(TWO_PI/3))*rTwo),diam,diam); ellipse (xpos+(cos(theta-(TWO_PI/3))*rTwo), ypos+(sin(theta-(TWO_PI/3))*rTwo),diam,diam); } } I'm excited to continue building upon this but I do not want to export the code everytime to test it out. If anyone has any insight as to why this is happening I would greatly appreciate it!