Using ofRandom(#,#)

I’m using ofRandom when drawing shapes but it’s not giving me the exact effect that I want. I’m considering two methods but not sure how to accomplish. ofRandom(5,100) just draws the shape (let’s say a circle) which randomly changes (rapidly) between radius 5 and 100.

Solution 1:
What I’d like is that when I draw it randomly selects a radius between 5 and 100 and stays at that radius.

Solution 2:
I’m also interested in a smooth transition between 5 and 100… so radius might start at 5…then 6…7…8…9…to 100 and back.

Are there any examples that might provide good insight or perhaps this is an easy fix?

solution 1:

  
  
...  
float radius;  
...  
void testApp::setup(){  
   radius = ofRandom(5,100);  
   ...  
}  
...  
void testApp::draw(){  
   ...  
   ofCircle(ofGetWidth()/2,ofGetHeight()/2,radius);  
   ...  
}  
  

solution 2:

  
  
...  
int radius = 5;  
...  
void testApp::draw(){  
   ...  
   ofCircle(ofGetWidth()/2,ofGetHeight()/2,radius);  
   radius++;  
   ...  
}  
  

thanks that did it. :slight_smile: