Again this is fairly self-explanatory. Below are the result and the corresponding code. If it should not work on mobile, just click this link. It will open up in a new browser.
Color of rectangle changes when you move the mouse
var x; function setup() { createCanvas(400, 400); } function draw() { x = map(mouseX, 0, 400, 0, 255) y = map(mouseY, 0, 400, 255, 0) background(225); //rectangle fill(x) noStroke() rectMode(CENTER) rect(200, 200, 50, 50) //console.log(x) }