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.
Page Index Toggle Pages: 1
leaving trails (Read 700 times)
leaving trails
Aug 3rd, 2006, 4:10am
 
Hi,

Is there a way that I can make the line leave a trail while the box doesn't leave a trail?

Thanks,
annemarie




import processing.opengl.*;

float count = 0;
float count2 = 0;
//////////////////////////////////////
STROKE trail;
class STROKE {
 void leaveTrail() {
   count=count+0.3;
   if(count >= 200) { count = 0; }
   stroke(255);
   rect(30+count, 100, 2, 30);
 }
}
//////////////////////////////////////
RECT rectTrail;
class RECT {
 void noTrail() {
 count2=count2+0.1;
 if(count2 >= 50) { count2 = 0; }
 stroke(255);
 rect(0, 100-count2, 30, 30);
 }
}
//////////////////////////////////////
void setup(){
 size(200,200, OPENGL);
 trail = new STROKE();
 rectTrail = new RECT();
}


void draw(){
background(0);
 
 trail.leaveTrail();  
 rectTrail.noTrail();
}
Re: leaving trails
Reply #1 - Aug 3rd, 2006, 11:44am
 
Yes, you need a PGraphic object where you draw the lines. Then you draw the PGraphic to the applet an then you draw the rect to the applet.
Re: leaving trails
Reply #2 - Aug 3rd, 2006, 12:35pm
 
Here is piece of code to show how to generate a PGraphic object and how to use them:

Quote:



PGraphics graphic;
void setup(){
 size(400, 400,P3D);
 graphic = createGraphics(width, height,P3D,null);
 graphic.defaults();
 graphic.background(125);
}
void draw(){
 graphic.line(0,0,mouseX,mouseY);
 image(graphic,0,0);
}


Page Index Toggle Pages: 1