From 8dd2522b16c2259448a7d35e7a027626b2326d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Sat, 4 Apr 2020 00:35:40 +0200 Subject: [PATCH] Add UiText class --- src/ui/UiText.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ui/UiText.py b/src/ui/UiText.py index 2200d35..e3537ef 100644 --- a/src/ui/UiText.py +++ b/src/ui/UiText.py @@ -1,5 +1,17 @@ -import src.ui.UiElement as UiElement +from typing import Tuple + +import pygame + +from src.ui.UiElement import UiElement class UiText(UiElement): - pass + def __init__(self, rect: pygame.Rect, text: str, font: pygame.font.Font = None, + textColor: Tuple[int, int, int] = (0, 0, 0), antialias: bool = False, + backgroundColor: Tuple[int, int, int] = None): + super().__init__(rect) + + if font is None: + font = pygame.font.Font(None, 12) + + self.image = font.render(text, antialias, textColor, backgroundColor)