diff options
author | Viljami Ilola <+@hix.fi> | 2024-04-08 18:47:32 +0300 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-04-08 18:47:32 +0300 |
commit | da33fc2f82a2919f9af7c7d1c8510c37435c5181 (patch) | |
tree | b23636b4560e1ae3479880cc07e91c3f38321bc7 /src/sliceitoff | |
parent | 74a735a7878bc76d01b644505f674cfe7bebd058 (diff) |
background
Diffstat (limited to 'src/sliceitoff')
-rw-r--r-- | src/sliceitoff/display/display.py | 14 |
1 files changed, 13 insertions, 1 deletions
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]) |