D
D
davc2018-07-07 04:20:40
JavaScript
davc, 2018-07-07 04:20:40

How to make clearRect round in JavaScript?

Hello, I have such canvas and such js
<canvas id="c1" width="450" height="450"></canvas>

var canvas = document.getElementById('c1');
var ctx = canvas.getContext('2d');


ctx.fillStyle = '#00bf54';
ctx.fillRect(0, 0, 450, 450);
    canvas.onmousedown = function (event) {
        canvas.onmousemove = function (event) {
        var x = event.clientX;
        var y = event.clientY;
        ctx.clearRect(x+0, y+0, 45, 45);

    }
    canvas.onmouseup = function () {
        canvas.onmousemove = null;
    }
}

when clicked and moved, the canvas block is removed through clearRect with squares.
How to make circles instead of squares?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question