We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › sketch vs. applet
Page Index Toggle Pages: 1
sketch vs. applet? (Read 715 times)
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!
Re: sketch vs. applet?
Reply #1 - May 16th, 2006, 12:26am
 
That behavior could simply be the Java plugin caching an old (working) version of the applet and something is wrong with your new version...

It works fine for me though, so all I can imagine is restarting processing or updating.

Marcello
Re: sketch vs. applet?
Reply #2 - May 16th, 2006, 4:45pm
 
what platform are you using? perhaps linux?
Re: sketch vs. applet?
Reply #3 - May 16th, 2006, 6:40pm
 
right now im working on somewhat of a shotty windows, so i wouldnt be surprised if its just this computer lacking in something.  I am a bit confused because i downloaded the newest version of processing onto this computer.  This is only temporary because my real computer is a G4 Powerbook with os x 10.4.  I guess I will have to wait a while to know for sure.
a lost sketch
Reply #4 - May 17th, 2006, 5:39pm
 
i don't know where to post this:
i have seen somewhere a while back a very nice processing sketch called "pipes" i believe, where the mouse displacement makes the image (of pipes) slowly appear.
does that ring a bell to someone?
i would like very much to find this sketch again, please tell me where it is!
Re: sketch vs. applet?
Reply #5 - May 17th, 2006, 6:12pm
 
frogeraie,

yes you've posted in the wrong place. section "programs" is fine, but make sure to start a new topic for a new question ..

is this the sketch you were looking for:
dots_not_pipe

F
Page Index Toggle Pages: 1