diff --git a/src/App.vue b/src/App.vue index c4f0d25..39dbfbd 100644 --- a/src/App.vue +++ b/src/App.vue @@ -136,10 +136,10 @@ function draw() { const imgRatio = image.value.height / image.value.width; const widthFirst = image.value.width < image.value.height; - const imgWidth = targetSize.value * (widthFirst ? 1 : 1 / imgRatio); - const imgHeight = targetSize.value * (widthFirst ? imgRatio : 1); - const dx = (targetSize.value - imgWidth * zoom.value) * centerX.value; - const dy = (targetSize.value - imgHeight * zoom.value) * centerY.value; + const imgWidth = targetSize.value * (widthFirst ? 1 : 1 / imgRatio) * zoom.value; + const imgHeight = targetSize.value * (widthFirst ? imgRatio : 1) * zoom.value; + const dx = (targetSize.value - imgWidth) * centerX.value; + const dy = (targetSize.value - imgHeight) * centerY.value; // TODO get only selected area ctx.drawImage(image.value, dx, dy, imgWidth, imgHeight);