expanding circle with mouse click

Hi,
I’m having some serious trouble trying to implement this idea that when the mouse is clicked a circle slowly expands from that point. It then resets and re-expands when clicked at another point on screen.
I’m sure it has less to do with openframeworks and more to do with time functions but i’m really struggling to understand how the work and measure durations.
Any help is greatly appreciated.

Thanks

This is an aproach. Updating the radius and position one Circle:

This are the parameters with the initial values:

  
  
float tetha,radius, maxRadius, vel, xPos, yPos;  
//--------------------------------------------------------------  
void testApp::setup(){  
    tetha=180;  
    maxRadius=300;  
    vel=1;  
    yPos=0;  
    xPos=0;  
}  
  

Then update the radius of the circle each frame:
void testApp::update(){

if(tetha<180)
{
tetha+=vel;
}
radius=maxRadius*sin(PI*tetha/180);
}

Thes sinus function varies from -1 to 1, as long as the input parameter goes from 0 to 2*PI radians or 360 degrees. We just want to get half of the cicle from 0 to 180. Then as we are incrementing in degrees we must translate it to radians for the sinus function.

Change the position and reset tetha qhen mosue clicked

  
void testApp::mousePressed(int x, int y, int button){  
    tetha=0;  
    xPos=x;  
    yPos=y;  
  
}  

draw it:

  
void testApp::draw(){  
  
    ofSetColor(200,30,30);  
    ofCircle(xPos,yPos,radius);  
  
}  

For more elaborated tweens look for http://code.google.com/p/tweener/
it has a c++ implementation for OF