nvas.addEventListener('click', function(event) {
        let elemLeft = canvas.offsetLeft + canvas.clientLeft;
        let elemTop = canvas.offsetTop + canvas.clientTop;
        anchorX = event.pageX - elemLeft;
        anchorY = event.pageY - elemTop;
        render();
    });

    // To handle zoom levels
    function scaleDOMRect(rect, scale) {
        rect.x = rect.x * scale;
        rect.y = rect.y * scale;
        rect.width = rect.width * scale;
        rect.height = rect.height * scale;