I'm trying to make a drawing program using javascript and the HTML canvas, and I need to continuously draw a circle at the location of the mouse, and I'm not exactly sure how to do it. I have a rough idea but my code (not surprisingly) doesn't work. Any idea how I can make it work? the code is here.
<canvas width = '450' height = '450' id = 'drawing'> </canvas>
<script>
var canvas = document.getElementById('drawing');
var ctx = canvas.getContext('2d')
var drawing = false
function startmoving(){ drawing = true;}
function stopmoving() { drawing = false;}
function draw() {
if (drawing == true){
ctx.fillstyle = 'black';
ctx.fillRect(event.clientX, event.clientY, 4, 4)
}
setInterval(drawing, 10);
}
</script>