Functions for rendering graphics
set_default_filter_mode(filter: FilterMode) → Noneset_default_filter_mode(filter: FilterMode) → NoneSet the default FilterMode for new textures. The factory default is FilterMode::Default.
Args
filter : The default scaling/filtering mode to use for new textures.get_default_filter_mode() → FilterModeget_default_filter_mode() → FilterModeGet the current default FilterMode for new textures.
Returns
FilterMode : The current default scaling/filtering mode.
clear(color: Color = ...) → Noneclear(color: Color = ...) → 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.present() → Nonepresent() → 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.
set_virtual_resolution(width: int, height: int) → Noneset_virtual_resolution(width: int, height: int) → NoneSet a virtual resolution for rendering. This creates an internal render target of the specified size, and all rendering will be done to that target, which is then scaled up to the actual screen resolution when presented.
Args
width : The width of the render target in pixels.height : The height of the render target in pixels.Raises
ValueError : If width or height are not positive integers.unset_virtual_resolution() → Noneunset_virtual_resolution() → NoneUnset any previously configured virtual resolution and restore rendering directly to the output.
set_render_backend(backend: RenderBackend) → Noneset_render_backend(backend: RenderBackend) → NoneSet the renderer backend to use for future initialization. This must be called before creating the window/renderer, otherwise it will have no effect.
Args
backend : One of the RenderBackend enum values.get_virtual_resolution() → Vec2get_virtual_resolution() → Vec2Get the currently configured virtual resolution (the internal render target size). If no virtual resolution is set, this returns the current output resolution.
Returns
Vec2 : The width and height of the virtual resolution in pixels.
get_output_resolution() → Vec2get_output_resolution() → Vec2Get the renderer's output/presenting resolution (the actual window or output size).
Returns
Vec2 : The output width and height in pixels.
get_current_resolution() → Vec2get_current_resolution() → Vec2Get the resolution of the current render target for rendering. If a custom render target is set, this will return the size of it. Otherwise, it returns the presenting resolution of the renderer.
Returns
Vec2 : The width and height of the current resolution.
set_target(target: Texture | None = None) → Noneset_target(target: Texture | None = None) → NoneSet the current render target to the provided Texture.
Args
target : A Texture created with TextureAccess.TARGET, or None to unset.Raises
RuntimeError : If the texture is not a TARGET texture.draw_9slice(texture: Texture, dst: Rect, slice: Rect, anchor: Vec2 = ..., pivot: Vec2 = ...) → Nonedraw_9slice(texture: Texture, dst: Rect, slice: Rect, anchor: Vec2 = ..., pivot: Vec2 = ...) → NoneRender a texture using 9-slice scaling (9-grid). The camera's transform is not applied to this draw.
This divides the texture into 9 regions: 4 corners (unscaled), 4 edges (scaled in one axis), and 1 center (scaled in both axes).
Args
texture : The source texture.dst : The destination rectangle on screen.slice : A rectangle defining the slice widths/heights (left_width, top_height, right_width, bottom_height).anchor : The anchor point. Defaults to top left.pivot : The rotation pivot. Defaults to center.read_pixels(src: Rect = ...) → PixelArrayread_pixels(src: Rect = ...) → 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 or area has no width or height.Returns
PixelArray : An array containing the pixel data.
Raises
RuntimeError : If reading pixels fails.