Renderer
Functions for rendering graphics
Clear
clear(color: Any = None) → NoneClear the renderer with the specified color.
Args
color: The color to clear with. Defaults to black (0, 0, 0, 255).
Raises
ValueError: If color values are not between 0 and 255.
clear(
r: SupportsInt,
g: SupportsInt,
b: SupportsInt,
a: SupportsInt = 255
) → NoneClear the renderer with the specified color.
Args
r: Red component (0-255).g: Green component (0-255).b: Blue component (0-255).a: Alpha component (0-255). Defaults to 255.
Draw
draw(
texture: Texture,
transform: Any = None,
anchor: Any = None,
pivot: Any = None
) → NoneRender a texture.
Args
texture: The texture to render.transform: The transform (position, rotation, scale).anchor: The anchor point (0.0-1.0). Defaults to top left (0, 0).pivot: The rotation pivot (0.0-1.0). Defaults to center (0.5, 0.5).
Get Default Scale Mode
get_default_scale_mode() → TextureScaleModeGet the current default TextureScaleMode for new textures.
Returns
TextureScaleMode : The current default scaling/filtering mode.
Get Target Resolution
get_target_resolution() → Vec2Get the resolution of the current render target. If no target is set, returns the logical presentation resolution.
Returns
Vec2 : The width and height of the render target.
Present
present() → NonePresent the rendered content to the screen.
This finalizes the current frame and displays it. Should be called after all drawing operations for the frame are complete.
Read Pixels
read_pixels(src: Any = None) → PixelArrayRead pixel data from the renderer within the specified rectangle.
Args
src: The rectangle area to read pixels from. Defaults to entire renderer if None.
Returns
PixelArray : An array containing the pixel data.
Raises
RuntimeError: If reading pixels fails.
Set Default Scale Mode
set_default_scale_mode(scale_mode: TextureScaleMode) → NoneSet the default TextureScaleMode for new textures.
Args
scale_mode: The default scaling/filtering mode to use for new textures.
Set Target
set_target(target: Texture) → NoneSet the current render target to the provided Texture, or unset if None.
Args
target: Texture created with TextureAccess.TARGET, or None to unset.
Raises
RuntimeError: If the renderer is not initialized or the texture is not a TARGET texture.