fix: zoom not working as expected
This commit is contained in:
+4
-4
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user