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 & HelpSyntax Questions › Fading shapes, nonfading text
Page Index Toggle Pages: 1
Fading shapes, nonfading text (Read 1091 times)
Fading shapes, nonfading text
Feb 1st, 2010, 9:32am
 
hit a brick wall here - there must be a simple solution! Im working on a reacivision/reactable setup. i want objects which are placed on the table to be illuminated by a circle of light around their base, and with information about their ID, position and angle off to the side.

however, i want the pad/circle of light to fade so that you can see where the objects have been as they are moved around the table...while the information text needs to be refreshed for every frame without fading so they can be clearly read...

hope thats clear! the problem is that with drawing black boxes or similar around the text every frame to get rid of the old info - it also trapples right over the tails of the fading circles, and they gradually accumulate coverling the screen with permanent squares....

maybe im missing s trick here, i just want to refresh the text image every frame! here is the relevant code:

Quote:
 buffer.beginDraw();
       buffer.textFont(font, 44);
       buffer.stroke(150);        //border  
       buffer.text("test", tobj.getScreenX(width), tobj.getScreenY(height));
       buffer.endDraw();


then at the end of the draw(); loop  i have   image(buffer,0,0); 


i'm quite new to processing - i hope ive clearly described the problem...and i hope i've jsut missed something simple..

thanks in advance for any help,
FJ
Re: Fading shapes, nonfading text
Reply #1 - Feb 1st, 2010, 9:38am
 
Here is a similar problem: http://processing.org/discourse/yabb2/?num=1264911247
Re: Fading shapes, nonfading text
Reply #2 - Feb 1st, 2010, 10:37am
 
thanks for the quick reply...

yeah, i had seen that post, it is a similar problem, but in that script the non-fading shapes just keep piling up, eventually you're left with a red screen...

what i need is exactly like the post you linked to, but where there is only ever one rectangle present on the screen....

still banging my head....
Re: Fading shapes, nonfading text
Reply #3 - Feb 1st, 2010, 11:56am
 
Just use a second buffer for the single rectangle (or whatever).
Re: Fading shapes, nonfading text
Reply #4 - Feb 1st, 2010, 12:03pm
 
i've been trying that, with a couple of buffers, but i get one of two results:

either the rectangle fades too, or they stay permanently....

i think the problem is that the first thing i do with every draw() iteration is:

fill(100,5);
rect(0,0,width,height);

which gives me the fading, but also fades the rectangle depending on when i draw the buffer.....

...?
Re: Fading shapes, nonfading text
Reply #5 - Feb 1st, 2010, 12:51pm
 
thought i'd make up a little test program to make the problem (and hopefully the solution) a bit easier to see...any ideas?i want the circle to fade, while only ever having one rectangle on the screen at a time....
Quote:
float angle,speed;
PGraphics buffer;

void setup(){

 size(400,400);
 noStroke();
 speed=0.04;
 loop();
 smooth();

 buffer = createGraphics(width, height, P2D);  

}
void draw(){
 fill(20,5);

 noStroke();
 rect(0,0,width,height);

 angle+=speed;

 float X=width/2+sin(angle)*width/2;
 float Y=height/2+cos(angle)*width/3;

 stroke(255);
 int rad=height/6;
 ellipse(X,Y,width/8,height/8);

 buffer.beginDraw();
 buffer.stroke(255);
 buffer.noFill();
 buffer.rect(X/2,Y/2,width/8,height/8);
 buffer.endDraw();

 image(buffer,0,0);

}




Re: Fading shapes, nonfading text
Reply #6 - Feb 1st, 2010, 1:31pm
 
The method of using a second buffer:

Code:

float angle,speed;
PGraphics buffer;
PGraphics bufferCircle;

void setup(){

size(400,400);
noStroke();
speed=0.04;
loop();
smooth();

buffer = createGraphics(width, height, P2D);
bufferCircle = createGraphics(width, height, P2D);

}
void draw(){
bufferCircle.beginDraw();
bufferCircle.fill(20,5);
bufferCircle.noStroke();
bufferCircle.rect(0,0,width,height);

angle+=speed;

float X=width/2+sin(angle)*width/2;
float Y=height/2+cos(angle)*width/3;

bufferCircle.stroke(255);
int rad=height/6;
bufferCircle.ellipse(X,Y,width/8,height/8);
bufferCircle.endDraw();

buffer.beginDraw();
buffer.background(0, 0);
buffer.stroke(255);
buffer.noFill();
buffer.rect(X/2,Y/2,width/8,height/8);
buffer.endDraw();

image(bufferCircle,0,0);
image(buffer,0,0);

}
Re: Fading shapes, nonfading text
Reply #7 - Feb 1st, 2010, 1:37pm
 
whoa!

really really appreciated JR. i'll crack on with getting this to work with text. i've literally just copied and ran it so far, so i'll get my head round the method this evening....just wanted to say thanks - your version obviously works!
cheers,
FJ
Page Index Toggle Pages: 1