<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
Escolha uma cor: <input type="color" id="cor"><br><br>
<canvas width="600" height="400"></canvas>
<script>
var tela = document.querySelector('canvas');
var pincel = tela.getContext('2d');
let pressionado;
pincel.fillStyle = 'grey';
pincel.fillRect(0, 0, 600, 400);
tela.onmousedown = function clicado(){
pressionado = true;
}
tela.onmouseup = function naoClicado(){
pressionado = false;
}
tela.onmousemove = function desenhaCirculo(evento){
var x = evento.pageX - tela.offsetLeft;
var y = evento.pageY - tela.offsetTop;
var cores = document.getElementById("cor").value;
if(pressionado){
pincel.fillStyle = cores;
pincel.beginPath();
pincel.arc(x, y, 10, 0, 2 * 3.14);
pincel.fill();
console.log(x + ',' + y);
};
}
</script>
</body>
</html>