Match photo selection and rendered canvas to device rotation

This commit is contained in:
Pigway
2026-10-05 22:44:41 +08:00
parent 8139a646d7
commit 59345f12a7
13 changed files with 249 additions and 35 deletions
@@ -0,0 +1,10 @@
"""Resolve a device's visual canvas without coupling rendering to its driver."""
def frame_canvas(display, orientation=None):
width, height = display.width, display.height
if orientation == "landscape":
return max(width, height), min(width, height)
if orientation == "portrait":
return min(width, height), max(width, height)
return (height, width) if display.rotation % 180 == 90 else (width, height)