import functools
import time
+import pygame.surface
+import pygame.locals as pgl
from .constants import DEBUG
+from .loader import loader
def debug_timer(label, debug=False):
def end(self):
print " %s: %s" % ("total", time.time() - self.times[0])
print "---- ----"
+
+
+def shadowed_text(text, font_name, size, offset=4):
+ font_black = loader.load_font(font_name, size=size)
+ font_white = loader.load_font(font_name, size=size)
+ background = font_black.render(text, True, (0, 0, 0))
+ foreground = font_white.render(text, True, (255, 255, 255))
+ new_size = (background.get_width() + offset,
+ background.get_height() + offset)
+ base = pygame.surface.Surface(new_size, pgl.SWSURFACE).convert_alpha()
+ base.fill((0, 0, 0, 0))
+ base.blit(background, (offset, offset), None)
+ base.blit(foreground, (0, 0), None)
+ return base