<!DOCTYPE html>
<html lang="es">
<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>
    <center><canvas width="600px" height="400px"></canvas></center>
    <script>
        let canvas = document.querySelector("canvas");
        let ctx = canvas.getContext("2d");
        ctx.fillStyle = "#D8D8D8";
        ctx.fillRect(0, 0, 600, 400);
        let colors = ["#4ED5C7", "#D44865", "#B8DA8D"];
        let i = 0;
        function drawCircle(event) {
            let x = event.pageX - canvas.offsetLeft;
            let y = event.pageY - canvas.offsetTop;
            ctx.fillStyle = colors[i];
            ctx.beginPath();
            ctx.arc(x, y, 10, 0, 2 * 3.14);
            ctx.fill();
            console.log(x + "," + y);
        }
        function changeColor() {
            i += 1;
            if (i == colors.length) {
                i = 0;
            }
            return false;
        }
        canvas.onclick = drawCircle;
        canvas.oncontextmenu = changeColor;
    </script>
</body>
</html>
