diff options
author | Viljami Ilola <+@hix.fi> | 2024-03-27 15:47:05 +0200 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-03-27 15:47:05 +0200 |
commit | a0cbc5902996b52290afb486b3e2554e1abc123c (patch) | |
tree | 55f600717de02e961771932ad0e39080351f20cf /src/sliceitoff/text/text.py | |
parent | 61a1248e340d1c87a6c4e7dec77f1089984b87b6 (diff) |
colored texts
Diffstat (limited to 'src/sliceitoff/text/text.py')
-rw-r--r-- | src/sliceitoff/text/text.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/sliceitoff/text/text.py b/src/sliceitoff/text/text.py index 424bbc2..8c13004 100644 --- a/src/sliceitoff/text/text.py +++ b/src/sliceitoff/text/text.py @@ -2,7 +2,7 @@ import pygame from random import randrange from images import Fonts -from display import Scaling +from display import Scaling, EGA_COLORS scaled_fonts = {} @@ -38,6 +38,7 @@ class TextPage(pygame.sprite.Group): super().__init__() if grid == None: grid = size + color = 0xf col, row = 0, 0 x, y = pos w, h = grid @@ -49,14 +50,20 @@ class TextPage(pygame.sprite.Group): if ch_txt == '\t': col = (col + 4) % 4 continue - font_key = (font, w) ch = ord(ch_txt) + if ch in range(0xe0,0xf0): + color = ch - 0xe0 + continue + font_key = (font, w, color) if font_key not in scaled_fonts: scaled_fonts[font_key]=[None for _ in range(256)] if scaled_fonts[font_key][ch] == None: scaled_fonts[font_key][ch] = pygame.transform.scale_by( Fonts.fonts[font].get(ch), size[0]/8 * Scaling.factor) + scaled_fonts[font_key][ch].fill( + EGA_COLORS[color], + special_flags = pygame.BLEND_RGBA_MULT) image = scaled_fonts[font_key][ch] image_pos = Scaling.scale_to_display( (x+col*w, y+row*h) ) self.add(LetterSprite(image, image_pos)) |