Mouse with face

See the Pen LQwqze by NombreNombre (@NombreNombre) on CodePen.

This code is a simple code with the objective to move a face on a canvas and change the colour of the background.

To Start you must create variables with the letters R G B (Red green blue).

Then you must create the canvas inside of setup.

After that, create the function draw.

Then we create Maps. Maps are used to create effects that depends of a format. On this case, you must write this:

r=map(mouseX,0,"Canvas Width",0,255);

With this, we say from mouseX to the Canvas Width, you will get a random value fron 0 to 255.

Repat this process for variables B and G, on case of G, instead of mouseX, you must write mouseY.

After that, you create the background, and the colour of the background, you must write R G B.

On the fnal part, you create a face, with the geometrical forms.

During the creation of the face, when you will write where it will be located, you must write mouseX and mouseY, so it will move with the mouse.

And done, you have succesfully created a face that moves and changes the background colour depending of the location that the face is.