I would like to move a shape to wherever I have clicked on the canvas. This is my program. Please tell me what changes i need to make in this
int xPos;
int yPos;
void setup()
{
size(500,500);
}
void draw()
{
background(0);
drawSquare();
mouseClicked();
}
void drawSquare()
{
final int RECT_WIDTH=300;
final int RECT_HEIGHT=200;
final int RECT_POS_X=(width-RECT_WIDTH)/2;
final int RECT_POS_Y=(height-RECT_HEIGHT)/2;
rect(RECT_POS_X,RECT_POS_Y,RECT_WIDTH,RECT_HEIGHT);
}
void mouseClicked()
{
xPos=mouseX;
yPos=mouseY;
}