diff options
author | Kshitij <Kshitij@Kshitijs-MacBook-Pro.local> | 2012-12-25 14:43:21 (GMT) |
---|---|---|
committer | Kshitij <Kshitij@Kshitijs-MacBook-Pro.local> | 2012-12-25 14:43:21 (GMT) |
commit | 139087f88bf94b23b736d06206f16ed79612a93b (patch) | |
tree | 057ec70cb569663ecdd27cc3a896183ce51de241 /olpcgames/textsprite.py | |
parent | 1315986303a98f0f93087c8c36af1886c86e4d1c (diff) |
Diffstat (limited to 'olpcgames/textsprite.py')
-rw-r--r-- | olpcgames/textsprite.py | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/olpcgames/textsprite.py b/olpcgames/textsprite.py deleted file mode 100644 index 7663630..0000000 --- a/olpcgames/textsprite.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Simple Sprite sub-class that renders via a PangoFont""" -from pygame import sprite -from olpcgames import pangofont - -class TextSprite( sprite.Sprite ): - """Sprite with a simple text renderer""" - image = rect = text = color = background = None - def __init__( self, text=None, family=None, size=None, bold=False, italic=False, color=None, background=None ): - super( TextSprite, self ).__init__( ) - self.font = pangofont.PangoFont( family=family, size=size, bold=bold, italic=italic ) - self.set_color( color ) - self.set_background( background ) - self.set_text( text ) - def set_text( self, text ): - """Set our text string and render to a graphic""" - self.text = text - self.render( ) - def set_color( self, color =None): - """Set our rendering colour (default white)""" - self.color = color or (255,255,255) - self.render() - def set_background( self, color=None ): - """Set our background color, default transparent""" - self.background = color - self.render() - def render( self ): - """Render our image and rect (or None,None) - - After a render you will need to move the rect member to the - correct location on the screen. - """ - if self.text: - self.image = self.font.render( self.text, color = self.color, background = self.background ) - currentRect = self.rect - self.rect = self.image.get_rect() - if currentRect: - self.rect.center = currentRect.center - else: - self.rect = None - self.image = None |