Documentation Index | From module rabbyt.fonts.

FontSprite

FontSprite(font, text, ...)

A sprite that displays text from a Font.

font should be a rabbyt.fonts.Font instance to be used.

text is the string to be displayed! (It can be changed later with the text property.)

This inherits from BaseSprite, so you can use all of the transformation and color properties.

Methods

attrgetter

attrgetter(name)

Returns an anim that returns the value of the given attribute name.

Perhaps this is easiest to see with an example. The following two lines will do the same thing, only the second is much, much faster:

sprite.x = lambda: other_sprite.x

sprite.x = other_sprite.attrgetter("x")

The anim returned by attrgetter is implemented in Pyrex (C) and will retrieve the value without doing a python attribute lookup.

This doesn't work for all attributes -- only x, y, scale, rot, red, green, blue, and alpha. (Subclasses might add others.)

convert_offset

convert_offset((x, y)) -> (x, y)

Converts coordinates relative to this sprite to global coordinates, including rotation and scaling.

render

render()

Renders the sprite.

By default, this method will transform the OpenGL modelview matrix according to x, y, scale, and rot, and call render_after_transform().

If you want transformations to be handled for you, leave this method and override render_after_transform(). Otherwise, override render().

render_after_transform

Properties

alpha

alpha color component

blue

blue color component

bounding_radius

bounding_radius

This should be the distance of the farthest point from the center. It can be used for collision detection.

bounding_radius_squared

bounding_radius_squared

This is just like bounding_radius, only it's squared. (duh)

bounding_radius and bounding_radius_squared are automatically kept in sync with each other.

green

green color component

red

red color component

rgb

red, green, and blue color components

rgba

red, green, blue, and alpha color components

rot

rotation

scale

scale

1.0 is normal size; 0.5 is half size, 2.0 is double size... you get the point.

You can scale the x and y axes independently by assigning a tuple with a length of two.

x

x coordinate

xy

A tuple of the x and y coordinates

y

y coordinate