ataURL(file);
});
function drawImage(){
ctx.clearRect(0,0,canvas.width,canvas.height);
ctx.save();
ctx.translate(offsetX,offsetY);
ctx.scale(scale,scale);
ctx.drawImage(image,0,0);
ctx.drawImage(maskCanvas,0,0);
if(currentTool==='polygonSelect'&&currentSelection.length>0){
drawSelectionPreview();
}
ctx.restore();
}
canvas.addEventListener('mousedown',startDrawing);
canvas.addEventListener('mousemove',draw);
canvas.addEventListener('mouseup',stopDrawing);
canvas.addEventListener('mouseout',stopDrawing);
canv