//Initial variables for the whole sketch

//Defines a list of colors called 'colorList' with 3 colors
color[] colorList = {color(255,255,0,70),color(200,0,125,70),color(0,100,255,70)};

//Defines 3 numbers (x and y for the circle coordinates and r for its radius)
float x,y,r;

//Initial conditions
void setup(){

//Defines the size of the window
size(displayWidth,displayHeight);

//Defines the background color
background(255);

//Defines the initial value of x
x=width/2;

//Defines the initial value of y
y=height/2;

//Defines the initial size of the radius
r=50;

//Defines a high frameRate (the more frequent it is, the more fluid the sketch will be)
frameRate(60);

//Sets the initial position of the mouse otherwise we have (0,0)
mouseX=width/2;
mouseY=height/2;
}

//Defines what the program does with each reading of the sketch (here 60 times per second)
void draw(){

//Defines a rondom color picked from the list 'colorList' (we get the length of the list, that is, the number of elements inside)
color randomColor = colorList[(int)random(colorList.length)];

//Defines the filling with the random color picked
fill(randomColor);

//Defines that there is no stroke
noStroke();

//Draws a circle
ellipse(x, y, r, r);

//Establishes a condition: if x is less than the horizontal coordinate of the mouse...
if(x
//... then x is incremented by a portion of its distance to the mouse
x=x+dist(x,y,mouseX,mouseY)/10;
}

// if the condition is not fulfilled then...
else{

//... then x is decremented a portion of its distance to the mouse
x=x-dist(x,y,mouseX,mouseY)/10;
}

//Establishes a condition: if y is less than the vertical coordinate of the mouse...
if(y
//... then y is incremented by a portion of its distance to the mouse
y=y+dist(x,y,mouseX,mouseY)/10;
}

//if the condition is not fulfilled then...
else{

//... then y is decremented a portion of its distance to the mouse
y=y-dist(x,y,mouseX,mouseY)/10;
}
//Establishes a condition: if the radius is bigger than 140 pixels
if(r>140){
//Decrements r by 1
r--;
}

//Establishes a condition: if the radius is less than 5 pixels
if(r<5){
//Increments r by 1
r++;
}

//In case none of the above are true...
else{

//Defines a rondom increment for the radius between -10 and +10
r+=random(-10.0,10.0);
}

//Resets a white interface when the key ENTER is pressed
if(keyPressed){
if(key==ENTER){
background(255);
}
}
}