Renderer
Functions for managing rendering operations and the render target.
Clear
clear(color: Color = None) → None
Clear the current render target with the specified color.
Parameters
color
: The color to clear with. If omitted, black is used.
clear(r: int, g: int, b: int, a: int = 255) → None
Clear the current render target with the specified RGBA color components.
Parameters
r
: Red component (0-255).g
: Green component (0-255).b
: Blue component (0-255).a
: Alpha component (0-255), defaults to 255 (opaque).
Present
present() → None
Present the current render target to the display, swapping buffers.
Draw
draw(texture: Texture, dst: Rect, src: Rect = None) → None
Render the texture within the specified destination rectangle, optionally using a source rectangle to select a portion of the texture.
Parameters
texture
: The texture to draw.dst
: The destination rectangle to render the texture into.src
: An optional source rectangle to select a portion of the texture.
draw(texture: Texture, pos: Vec2 = None, anchor: Anchor = CENTER) → None
Render the texture at the specified position, optionally using an anchor point to control the alignment.
Parameters
texture
: The texture to draw.pos
: The position to render the texture.anchor
: The anchor point for alignment.
Get Res
get_res() → Vec2
Get the current resolution of the renderer's output target.
Returns
Vec2
: The width and height of the render target in pixels.
Read Pixels
read_pixels(src: Rect = None) → PixelArray
Read pixel data from the current render target within the specified rectangle.
Parameters
src
: The source rectangle to read pixels from. If omitted, the entire render target is read.
Returns
PixelArray
: The pixel data read from the render target.