From da33fc2f82a2919f9af7c7d1c8510c37435c5181 Mon Sep 17 00:00:00 2001 From: Viljami Ilola <+@hix.fi> Date: Mon, 8 Apr 2024 18:47:32 +0300 Subject: background --- src/sliceitoff/display/display.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sliceitoff/display/display.py b/src/sliceitoff/display/display.py index 65b4713..a161dc4 100644 --- a/src/sliceitoff/display/display.py +++ b/src/sliceitoff/display/display.py @@ -7,6 +7,14 @@ from .static import CGA_COLORS DEBUG = os.getenv("DEBUG") +def gen_backdrop(color, color2): + """ generates backdrop with 50% dithering """ + srfc = pygame.Surface((320, 240)) + for x in range(320): + for y in range(240): + srfc.set_at((x,y),color if (x+y)%2 else color2) + return srfc + class Display(): """display.Display - Handles graphics. Init, clear, draw, borders... """ @@ -18,6 +26,9 @@ class Display(): pygame.FULLSCREEN | pygame.SCALED, vsync = 1 ) Scaling.update_scaling(self.screen.get_size()) + self.backdrop = pygame.transform.scale_by( + gen_backdrop(CGA_COLORS[1], CGA_COLORS[8]), + 1_000 * Scaling.factor) if DEBUG: print( "DISPLAY: \n" @@ -30,7 +41,8 @@ class Display(): def update(self, groups = None): """ Updates the screen: clear, blit gropus and flip """ - self.screen.fill(CGA_COLORS[4], rect=Scaling.active) + self.screen.blit(self.backdrop, (Scaling.left,Scaling.top)) + # fill(CGA_COLORS[4], rect=Scaling.active) for group in groups: group.draw(self.screen) self.screen.fill(0, rect=Scaling.borders[0]) -- cgit v1.2.3