<canvas width="600" height="400"></canvas>
<p>Escolha uma cor: <input id="color" type="color"></p>
<script>
var canvas = document.querySelector('canvas');
var color = document.querySelector('input');
var pincel = canvas.getContext('2d');
var paint = false;
pincel.fillStyle = 'grey';
pincel.fillRect(0, 0, 600, 400);
function paintOn(evento) {
var x = evento.pageX - canvas.offsetLeft;
var y = evento.pageY - canvas.offsetTop;
if (paint) {
pincel.fillStyle = color.value;
pincel.beginPath();
pincel.arc(x, y, 15, 0, 2 * 3.14);
pincel.fill();
}
}
function onOff() {
paint = !paint;
}
canvas.onmousemove = paintOn;
canvas.onmousedown = onOff;
canvas.onmouseup = onOff;
</script>