Movement trace

Hi there,

just a simple question. I’m trying to obtain the trace of a moving object in OF, the same effect we have in processing in the example here below:

float x = 0.0;

void setup(){
size(400,400);
}
void draw(){
x = x+0.5;
fill(255);
rect(x,x,20,20);
noStroke();
fill(0,0,0,10);
rect(0,0,width,height);
if (x>width){
x = 0;
}

I’ve tried in many ways, using no background or adding ofEnableAlphaChannel() but nothing seems to work…

Is there any good soul who can help me?

Thank you all,

videotrope

ex.tiff

In Setup:

  
ofSetBackgroundAuto(false); //tells OF to not auto clear  

In Draw Method:

  
ofEnableAlphaBlending();  
ofFill();  
ofSetColor(0, 0, 0, alpha); //* see note  
ofRect(0, 0, ofGetWidth(), ofGetHeight()); //draw a barely visible black rectangle  
ofDisableAlphaBlending(); //this may or may not be needed depending on what comes after  
// Draw whatever you'd like after . . .  

*Where alpha is a small number (i.e., 4). Play around with this value to make the trace stay longer or shorter.

I think that’s what you’re after. Have fun.

Hey mate,

thank you. Everything seems to turn into the right way.

Videotrope