sdl2.ext.draw - 2D drawing routines for software surfaces

sdl2.ext.draw.prepare_color(color : object, target : object) → int

Prepares the passed color for a specific target. color can be any object type that can be processed by sdl2.ext.color.convert_to_color(). target can be any sdl2.pixels.SDL_PixelFormat, sdl2.surface.SDL_Surface or sdl2.ext.sprite.SoftwareSprite instance.

The returned integer will be a color value matching the target’s pixel format.

sdl2.ext.draw.fill(target : object, color : object[, area=None]) → None

Fills a certain area on the passed target with a color. If no area is provided, the entire target will be filled with the passed color. If an iterable item is provided as area (such as a list or tuple), it will be first checked, if the item denotes a single rectangular area (4 integer values) before assuming it to be a sequence of rectangular areas to fill with the color.

target can be any sdl2.surface.SDL_Surface or sdl2.ext.sprite.SoftwareSprite instance.

sdl2.ext.draw.line(target : object, color : object[, width=1]) → None

Draws one or multiple lines on the passed target. line can be a sequence of four integers for a single line in the form (x1, y1, x2, y2) or a sequence of a multiple of 4 for drawing multiple lines at once, e.g. (x1, y1, x2, y2, x3, y3, x4, y4, ...).

target can be any sdl2.surface.SDL_Surface or sdl2.ext.sprite.SoftwareSprite instance.

Previous topic

sdl2.ext.compat - Python compatibility helpers

Next topic

sdl2.ext.ebs - A component-based entity system framework

This Page