| 1 | export function fitDeviceFrame(aspect: number, width: number, height: number, rightInset = 0) { |
| 2 | const availableWidth = Math.max(0, width - rightInset); |
| 3 | if (availableWidth === 0 || height === 0) return { width: 0, height: 0 }; |
| 4 | const byHeight = { width: height * aspect, height }; |
| 5 | return byHeight.width <= availableWidth |
| 6 | ? byHeight |
| 7 | : { width: availableWidth, height: availableWidth / aspect }; |
| 8 | } |