x.globalCompositeOperation='destination-out';
}
maskCtx.beginPath();
maskCtx.moveTo(lastX,lastY);
maskCtx.lineTo(x,y);
maskCtx.stroke();
const radius=brushSize.value/2;
maskCtx.beginPath();
maskCtx.arc(x,y,radius,0,Math.PI*2);
maskCtx.fill();
[lastX,lastY]=[x,y];
drawImage();
}
}
function stopDrawing(){
isDrawing=false;
}
function getCanvasCoordinates(e){
const rect=canvas.getBoundingClientRect();
return [
(e.clientX-rect.left-offsetX)/scale,
(e.clientY-rect.top-offsetY)/scale
];
}
function handleSelection(