Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import pygame
- def blurSurf(surface, amt):
- scale = 1.0 / float(amt)
- surf_size = surface.get_size()
- scale_size = (int(surf_size[0] * scale), int(surf_size[1] * scale))
- surf = pygame.transform.smoothscale(surface, scale_size)
- surf = pygame.transform.smoothscale(surf, surf_size)
- return surf
- class Fontrenderer(object):
- def __init__(self):
- self.s_c = {}
- self.c = {}
- def render(self, font, text, color, surf, pos):
- if not (font, text, str(color)) in self.s_c.keys():
- (self.s_c)[(font, text, str(color))] = blurSurf(font.render(text.decode('utf-8'),
- True, (0, 0, 0)), 1.6)
- ss = (self.s_c)[(font, text, str(color))]
- surf.blit(ss, (pos[0] + 1, pos[1] + 2))
- if not (font, text, str(color)) in self.c.keys():
- (self.c)[(font, text, str(color))] = font.render(text.decode('utf-8'),
- True, color)
- s = (self.c)[(font, text, str(color))]
- surf.blit(s, pos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement