Skip to content

Commit b537576

Browse files
committed
feat(fov): show zoomed-out preview for wider-than-source lenses in CropStrip
Instead of a text label, wider lenses now show the source image scaled down with the theme background visible around it, plus a dashed border in the lens color.
1 parent 0b1300e commit b537576

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,22 @@ function CropThumb({ lens, orientation, color, lensIndex, onSelect, offset, clea
9393
)
9494

9595
if (ratioW > 1.01 || ratioH > 1.01) {
96-
const fontSize = 11 * dpr
97-
ctx.font = `600 ${fontSize}px -apple-system, BlinkMacSystemFont, sans-serif`
98-
ctx.fillStyle = 'rgba(0,0,0,0.4)'
96+
ctx.fillStyle = getComputedStyle(canvas).getPropertyValue('--bg-primary').trim() || '#0d0d0d'
9997
ctx.fillRect(0, 0, canvas.width, canvas.height)
100-
ctx.fillStyle = color
101-
const text = `${lens.focalLength}mm — wider`
102-
const textW = ctx.measureText(text).width
103-
ctx.fillText(text, (canvas.width - textW) / 2, (canvas.height + fontSize) / 2)
98+
const innerW = canvas.width / ratioW
99+
const innerH = canvas.height / ratioH
100+
const innerX = (canvas.width - innerW) / 2
101+
const innerY = (canvas.height - innerH) / 2
102+
if (img && img.complete && img.naturalWidth > 0) {
103+
ctx.drawImage(img, 0, 0, img.naturalWidth, img.naturalHeight, innerX, innerY, innerW, innerH)
104+
} else {
105+
ctx.drawImage(mainCanvas, 0, 0, mainW, mainH, innerX, innerY, innerW, innerH)
106+
}
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([])
104112
return
105113
}
106114

0 commit comments

Comments
 (0)