Skip to content

Commit 0b400e0

Browse files
committed
fix(fov): preserve aspect ratio in wider-than-source crop thumbs
Use uniform scale factor and remove dotted border.
1 parent b537576 commit 0b400e0

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

src/app/[locale]/fov-simulator/_components/CropStrip.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,16 @@ function CropThumb({ lens, orientation, color, lensIndex, onSelect, offset, clea
9595
if (ratioW > 1.01 || ratioH > 1.01) {
9696
ctx.fillStyle = getComputedStyle(canvas).getPropertyValue('--bg-primary').trim() || '#0d0d0d'
9797
ctx.fillRect(0, 0, canvas.width, canvas.height)
98-
const innerW = canvas.width / ratioW
99-
const innerH = canvas.height / ratioH
98+
const scale = Math.max(ratioW, ratioH)
99+
const innerW = canvas.width / scale
100+
const innerH = canvas.height / scale
100101
const innerX = (canvas.width - innerW) / 2
101102
const innerY = (canvas.height - innerH) / 2
102103
if (img && img.complete && img.naturalWidth > 0) {
103104
ctx.drawImage(img, 0, 0, img.naturalWidth, img.naturalHeight, innerX, innerY, innerW, innerH)
104105
} else {
105106
ctx.drawImage(mainCanvas, 0, 0, mainW, mainH, innerX, innerY, innerW, innerH)
106107
}
107-
ctx.strokeStyle = color
108-
ctx.lineWidth = 1 * dpr
109-
ctx.setLineDash([4 * dpr, 4 * dpr])
110-
ctx.strokeRect(innerX, innerY, innerW, innerH)
111-
ctx.setLineDash([])
112108
return
113109
}
114110

0 commit comments

Comments
 (0)