Sitelet https://github.com/python-ugame/micropython-stage/commit/d244bc24bb296d3ea881b6649db3453dcc28fc17
Skip to content

Commit d244bc2

Browse files
committed
Add automatic scaling to best use the display
Unless scale is explicitly set.
1 parent ee09f5c commit d244bc2

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎stage.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,15 @@ def clear(self):
348348
class Stage:
349349
buffer = bytearray(512)
350350

351-
def __init__(self, display, fps=6, scale=1):
352-
self.scale = scale
351+
def __init__(self, display, fps=6, scale=None):
352+
if scale is None:
353+
self.scale = max(1, display.width // 128)
354+
else:
355+
self.scale = scale
353356
self.layers = []
354357
self.display = display
355-
self.width = display.width // scale
356-
self.height = display.height // scale
358+
self.width = display.width // self.scale
359+
self.height = display.height // self.scale
357360
self.last_tick = utime.ticks_ms()
358361
self.tick_delay = 1000 // fps
359362

0 commit comments

Comments
 (0)