diff options
author | Viljami Ilola <+@hix.fi> | 2024-03-29 17:54:24 +0200 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-03-29 17:54:24 +0200 |
commit | 7765d20550a8d5680b624f6063b4d2b23a094fed (patch) | |
tree | de059fad53c58897bdef350b2c7bd7c17cc72dae /src/sliceitoff/text/text.py | |
parent | 43a58a7be48208f8d87ee5256c84008a02425ecf (diff) |
lint some more
Diffstat (limited to 'src/sliceitoff/text/text.py')
-rw-r--r-- | src/sliceitoff/text/text.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/sliceitoff/text/text.py b/src/sliceitoff/text/text.py index 85958e0..83367e0 100644 --- a/src/sliceitoff/text/text.py +++ b/src/sliceitoff/text/text.py @@ -1,9 +1,10 @@ """ text.text - letters, texts and scaling and coloring of fonts """ -import pygame from random import randrange -from .fonts import Fonts +import pygame + from display import Scaling, CGA_COLORS +from .fonts import Fonts scaled_fonts = {} @@ -20,7 +21,7 @@ class LetterSprite(pygame.sprite.Sprite): self.dead = True if font_key not in scaled_fonts: scaled_fonts[font_key]=[None for _ in range(256)] - if scaled_fonts[font_key][ch] == None: + if scaled_fonts[font_key][ch] is None: font, w, color = font_key scaled_fonts[font_key][ch] = pygame.transform.scale_by( Fonts.fonts[font].get(ch), @@ -35,6 +36,7 @@ class LetterSprite(pygame.sprite.Sprite): Scaling.factor * (1_000 - randrange(2_000))) def update(self, dt = 0, explode = 0, **kwargs): + """ All the movements for letters """ if explode and dt: self.rect = pygame.Rect( self.rect.x + self.direction[0] * dt, @@ -64,12 +66,10 @@ class TextPage(pygame.sprite.Group): grid = None, font = 'lcd'): super().__init__() - if grid == None: + if grid is None: grid = size color = 0xf col, row = 0, 0 - x, y = pos - w, h = grid for ch_txt in text: if ch_txt == '\n': row += 1 @@ -83,7 +83,8 @@ class TextPage(pygame.sprite.Group): color = ch - 0xe0 continue font_key = (font, size[0], color) - sprite_pos = Scaling.scale_to_display( (x+col*w, y+row*h) ) + sprite_pos = Scaling.scale_to_display( + (pos[0]+col*grid[0], pos[1]+row*grid[1]) ) self.add(LetterSprite(font_key, ch, sprite_pos)) col += 1
\ No newline at end of file |