All posts by /r/processing

New to processing – Need help!!

Hello! I am new to processing and also new to reddit! I created this code, and want to be able to click anywhere on the canvas and have the rectangle glide smoothly to the mousePressed position. As it is gliding, I want it to change in size in accordance to the X and Y coordinates. Does anyone know how I can do this? This is the closest I can get, and the rectangle glides away from the clicked position and keeps on going. I need it to glide to the mousePressed location and to stop when it reaches there. Then if I click again, it will move from that location to the next. I would appreciate any tips!!

float savedLocationX;

float savedLocationY;

float speed;

void setup()




void draw()



speed = 1/savedLocationX+1;


savedLocationY=savedLocationY+speed; rect(savedLocationX/2,savedLocationY/2,499*savedLocationY/500,200*savedLocationY/500);


void mouseClicked()


savedLocationX = mouseX;

savedLocationY = mouseY;


submitted by /u/pbchocochipcheerios
[link] [comments]