fabianmoronzirfas
11/8/2014 - 12:52 PM

recursive_contrain_value.pde

mode.id=processing.mode.java.JavaMode
mode=Java
int count = 0;
void setup(){
frameRate(1);
}

void draw(){
  int _x = recursiveConstrain();
  println("result " + _x);
  ellipse(_x,height/2,10,10);

}

int recursiveConstrain(){
  int x = int(random(-200,200));
 if(x < 0 || x > width){
   count++;
   println("calling myself " + count + " times on value " + x);
   x = recursiveConstrain(); 

 } 
 count =0;
  return x; 
}