how to do the the same with dist?
              in 
             Programming Questions 
              •  
              9 months ago    
            
 
           
             hi, i am a little confused with dist function
            
how to do the same (change fill colour) with dist
instead of if (y>height/2-12) in this example?
            
            
            
 
           
 
            
           how to do the same (change fill colour) with dist
instead of if (y>height/2-12) in this example?
- float speed;
 void setup(){
 size(500,500);
 
 }
 void draw(){
 background(0);
 float y= map(sin(speed),1,-1,height/2-10,0);
 fill(255);
 ellipse(width/2,height/2+y,20,20);
 stroke(255);
 line(width/2,height/2,width/2,height/2+y);
 rectMode(CENTER);
 // the same with dist, how?
 if (y>height/2-12){
 fill(255,0,255);
 }
 else{
 fill(255);
 }
 rect(width/2,height,50,20);
 
 speed+=0.05;
 }
 
              
              1  
            
 
            
 
 
          