Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/api/MultiLabel.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/MultiLabel.py')
-rwxr-xr-xsrc/api/MultiLabel.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/api/MultiLabel.py b/src/api/MultiLabel.py
index fdaaa3e..956adf3 100755
--- a/src/api/MultiLabel.py
+++ b/src/api/MultiLabel.py
@@ -13,7 +13,7 @@ class CMultiLabel(CSprite):
least 30 pixels per line (with the default font)
"""
- def __init__(self):
+ def __init__(self, transparent=False):
CSprite.__init__(self)
self.text = 'This\nis\nsample\ntext'
#self.font = pygame.font.Font("freesansbold.ttf", 20)
@@ -21,6 +21,7 @@ class CMultiLabel(CSprite):
self.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 20)
self.fgColor = ((0x00, 0x00, 0x00))
self.bgColor = ((0xFF, 0xFF, 0xFF))
+ self.transparent = transparent
self.center = (0, 0)
self.size = (300, 150)
self.createImage()
@@ -40,6 +41,8 @@ class CMultiLabel(CSprite):
def createImage(self):
self.image = pygame.Surface(self.size)
self.image.fill(self.bgColor)
+ if self.transparent:
+ self.image.set_colorkey(self.bgColor)
self.textLines = self.text.split('\n')
numLines = len(self.textLines)
@@ -47,8 +50,10 @@ class CMultiLabel(CSprite):
for lineNum in range(numLines):
currentLine = self.textLines[lineNum]
-
- fontSurface = self.font.render(currentLine, True, self.fgColor, self.bgColor)
+ if self.transparent:
+ fontSurface = self.font.render(currentLine, True, self.fgColor)
+ else:
+ fontSurface = self.font.render(currentLine, True, self.fgColor, self.bgColor)
#center the text
xPos = (self.image.get_width() - fontSurface.get_width())/2
yPos = lineNum * vSize