summaryrefslogtreecommitdiff
path: root/src/sliceitoff/display
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-20 16:59:13 +0200
committerViljami Ilola <+@hix.fi>2024-03-20 16:59:13 +0200
commit398eebe7829622c6983cb28528f2208b4d596f32 (patch)
tree411f5d2fa3b7fc8b5352bc3cda49621fbd858919 /src/sliceitoff/display
parent191110be33196866998da385fbc3107344d2bf73 (diff)
text to srites. cache scaled font sprites...
Diffstat (limited to 'src/sliceitoff/display')
-rw-r--r--src/sliceitoff/display/display.py12
-rw-r--r--src/sliceitoff/display/scaling.py32
-rw-r--r--src/sliceitoff/display/static.py4
3 files changed, 44 insertions, 4 deletions
diff --git a/src/sliceitoff/display/display.py b/src/sliceitoff/display/display.py
index 54b1586..2d6605f 100644
--- a/src/sliceitoff/display/display.py
+++ b/src/sliceitoff/display/display.py
@@ -1,9 +1,12 @@
+import os
import pygame
from stats import Stats
from .scaling import Scaling
+DEBUG = os.getenv("DEBUG")
+
class Display():
def __init__(self):
@@ -14,10 +17,17 @@ class Display():
pygame.FULLSCREEN | pygame.SCALED,
vsync = 1 )
Scaling.update_scaling(self.screen.get_size())
+ self.screen.fill(Stats.bordercolor)
+ if DEBUG:
+ print(
+ "DISPLAY: \n"
+ f" {Scaling.active = }\n"
+ f" {Scaling.border = }\n"
+ f" {Scaling.factor = }\n")
def update(self, groups = None):
""" Updates the screen: clear, blit gropus and flip """
- self.screen.fill(Stats.bgcolor)
+ self.screen.fill(Stats.bgcolor, rect=Scaling.active)
for group in groups:
group.draw(self.screen)
pygame.display.flip()
diff --git a/src/sliceitoff/display/scaling.py b/src/sliceitoff/display/scaling.py
index af307d1..f40d33c 100644
--- a/src/sliceitoff/display/scaling.py
+++ b/src/sliceitoff/display/scaling.py
@@ -6,6 +6,8 @@ class Scaling():
factor = 0.02
left = 0
top = 0
+ borders = (pygame.Rect(0,0,0,0), pygame.Rect(0,0,0,0))
+ active = pygame.Rect(0,0,0,0)
@staticmethod
def area_to_rect(area: tuple) -> pygame.Rect:
@@ -40,8 +42,36 @@ class Scaling():
__class__.factor = size[0] / INTERNAL_WIDTH
__class__.left = 0
__class__.top = (size[1] - INTERNAL_HEIGHT * __class__.factor) // 2
+ __class__.border = (
+ pygame.Rect(
+ 0,
+ 0,
+ size[0],
+ __class__.top),
+ pygame.Rect(
+ 0,
+ size[1] - __class__.top,
+ size[0],
+ __class__.top),
+ )
else:
__class__.factor = size[1] / INTERNAL_HEIGHT
__class__.left = (size[0] - INTERNAL_WIDTH * __class__.factor) // 2
__class__.top = 0
- \ No newline at end of file
+ __class__.border = (
+ pygame.Rect(
+ 0,
+ 0,
+ __class__.left,
+ size[1]),
+ pygame.Rect(
+ size[0] - __class__.left,
+ 0,
+ __class__.left,
+ size[1]),
+ )
+ __class__.active = pygame.Rect(
+ __class__.left,
+ __class__.top,
+ INTERNAL_WIDTH * __class__.factor,
+ INTERNAL_HEIGHT * __class__.factor)
diff --git a/src/sliceitoff/display/static.py b/src/sliceitoff/display/static.py
index af1cc67..a9f487a 100644
--- a/src/sliceitoff/display/static.py
+++ b/src/sliceitoff/display/static.py
@@ -1,2 +1,2 @@
-INTERNAL_WIDTH = 400_000
-INTERNAL_HEIGHT = 300_000
+INTERNAL_WIDTH = 320_000
+INTERNAL_HEIGHT = 240_000