-
Notifications
You must be signed in to change notification settings - Fork 1
/
Text.py
39 lines (30 loc) · 1.11 KB
/
Text.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# coding: utf-8
import pygame
import functions
class Text():
def __init__(self, text, font, color, size):
self.text = text
self.size = size
self.font = functions.getFont(font, self.size)
self.color = color
self.initialize()
def initialize(self):
self.surface = self.font.render(self.text, True, self.color)\
.convert_alpha()
self.rect = self.get_rect()
def changeFont(self, font = None):
self.font = functions.getFont(font, self.size)
self.initialize()
def changeColor(self):
self.surface = self.font.render(self.text, True, self.color)\
.convert_alpha()
self.initialize()
def get_rect(self):
return self.surface.get_rect()
def changeText(self):
self.surface = self.font.render(self.text, True, self.color)\
.convert_alpha()
def __repr__(self):
return "Position topleft : {}\
\nColor : {}\
\nText : {}".format(self.rect.topleft, self.color, self.size)