Home

Class lib2d.Drawable

An entity that renders a graphical source, such as an image, to the display.

Methods

def __init__(self, image=None, x=0, y=0, w=0, h=0, color=0xffffffff)

If an image is passed when creating a drawable, width and height are set to match the image's size if not given explicitly.

def draw(self)

Schedule this Drawable to be rendered when lib2d.render() is called.

The current state at the time of calling this function is what will be used when rendering. So it's possible to call draw, change this drawable's state, and call draw again to render in its new state.

Examples

# This will render the same green square at two locations.
>>> lib2d.init()
>>> d = lib2d.Drawable(x=100, y=0, w=100, h=100, color=0x00ff00ff)
>>> d.draw()
>>> d.y = 100
>>> d.draw()

Members

image

An Image (or a path to an image on the file system) to render when draw() is called.

x

How many pixels from the left of the screen to render.

y

How many pixels down from the top of the screen to render.

w

Width of this drawable.

h

Height of this drawable.

color

Multiplies each pixel value of the referenced image by this color (format: 0xRRGGBBAA).