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,
    transform: Transform = None,
    src: Rect = None
) None

Render a texture with the specified transform and source rectangle.

If transform has no size, it will then check if src has a size and use that. If neither have a size, it will use the full texture size.

Parameters

  • texture : The texture to render.
  • transform : The transform (position, rotation, scale, anchor, pivot). Defaults to identity transform.
  • src : The source rectangle from the texture. Defaults to entire texture if not specified.

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.