JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="ru">
<head>
</head>
<body>
<canvas class="canvas" width="400" height="200"></canvas>
</body>
</html>
CSS
.canvas {
border: 3px solid black;
}
JavaScript
let canvas = document.querySelector(".canvas");
let ctx = canvas.getContext("2d");
canvas.addEventListener("mousemove", function(event) {
let mouseX = event.offsetX;
let mouseY = event.offsetY;
ctx.fillStyle = "rgb(250, 150," + mouseY + ");";
ctx.fill();
ctx.rect(mouseX, mouseY, 5, 5);
});