diff options
author | Viljami Ilola <+@hix.fi> | 2024-03-29 16:46:50 +0200 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-03-29 16:46:50 +0200 |
commit | 43a58a7be48208f8d87ee5256c84008a02425ecf (patch) | |
tree | 8fee5e83861b7b1a382b26da4a089dc6872aa5b2 /src/sliceitoff/text/text.py | |
parent | 505ca2dead48d80b15f64f316218502bdc54daea (diff) |
docstring etc linting
Diffstat (limited to 'src/sliceitoff/text/text.py')
-rw-r--r-- | src/sliceitoff/text/text.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/sliceitoff/text/text.py b/src/sliceitoff/text/text.py index 198ff4f..85958e0 100644 --- a/src/sliceitoff/text/text.py +++ b/src/sliceitoff/text/text.py @@ -1,3 +1,4 @@ +""" text.text - letters, texts and scaling and coloring of fonts """ import pygame from random import randrange @@ -7,6 +8,13 @@ from display import Scaling, CGA_COLORS scaled_fonts = {} class LetterSprite(pygame.sprite.Sprite): + """ Single letter at given properties hopefully from cache + + args: + font_key: (font name, width to scale, color) + ch: 0-255 character on cp473 + color: 0-15 as in CGA palette + """ def __init__(self, font_key, ch, pos): super().__init__() self.dead = True @@ -25,7 +33,7 @@ class LetterSprite(pygame.sprite.Sprite): self.direction = ( Scaling.factor * (1_000 - randrange(2_000)), Scaling.factor * (1_000 - randrange(2_000))) - + def update(self, dt = 0, explode = 0, **kwargs): if explode and dt: self.rect = pygame.Rect( @@ -36,9 +44,18 @@ class LetterSprite(pygame.sprite.Sprite): self.direction = ( self.direction[0] * 0.95, self.direction[1] * 0.95 + 0.3) - class TextPage(pygame.sprite.Group): + """ Creates sprite group out of given text and parameters + + args: + + text Just text. \xe0 - \xef to cahnge color on cga palette + pos Position of right top corner in internal cooordinates + size Single character size (w,h) + grid Space for a character (w,h) + font Font loaded in Fonts.fonts dict + """ def __init__( self, text, |