fix: zoom not working as expected

This commit is contained in:
2025-12-20 21:19:56 +01:00
parent fdf5002496
commit 95d09d7750
+4 -4
View File
@@ -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);