mini_arcade_pygame_backend.ports.render ======================================= .. py:module:: mini_arcade_pygame_backend.ports.render .. autoapi-nested-parse:: Render port implementation for the pygame backend. Provides functionality to draw shapes and manage rendering state. Classes ------- .. autoapisummary:: mini_arcade_pygame_backend.ports.render.RenderPort Module Contents --------------- .. py:class:: RenderPort(window: mini_arcade_pygame_backend.ports.window.WindowPort, vp: mini_arcade_core.backend.viewport.ViewportTransform, background_color=(0, 0, 0)) Render port for the Mini Arcade native backend. :param native_backend: The native backend instance. :type native_backend: native.Backend :param vp: The viewport transform. :type vp: ViewportTransform .. py:method:: set_clear_color(r: int, g: int, b: int) Set the clear color for the renderer. :param r: Red component (0-255). :type r: int :param g: Green component (0-255). :type g: int :param b: Blue component (0-255). :type b: int .. py:method:: begin_frame() Begin a new rendering frame. .. py:method:: end_frame() End the current rendering frame. .. py:method:: set_clip_rect(x: int, y: int, w: int, h: int) Set the clipping rectangle. :param x: The x-coordinate of the clipping rectangle. :type x: int :param y: The y-coordinate of the clipping rectangle. :type y: int :param w: The width of the clipping rectangle. :type w: int :param h: The height of the clipping rectangle. :type h: int .. py:method:: clear_clip_rect() Clear the clipping rectangle. .. py:method:: draw_rect(x: int, y: int, w: int, h: int, color=(255, 255, 255)) Draw a filled rectangle. :param x: The x-coordinate of the rectangle. :type x: int :param y: The y-coordinate of the rectangle. :type y: int :param w: The width of the rectangle. :type w: int :param h: The height of the rectangle. :type h: int :param color: The color of the rectangle as an (R, G, B) or (R, G, B, A) tuple. :type color: tuple[int, int, int] | tuple[int, int, int, int] .. py:method:: draw_line(x1: int, y1: int, x2: int, y2: int, color=(255, 255, 255), thickness=5) Draw a line between two points. :param x1: The x-coordinate of the start point. :type x1: int :param y1: The y-coordinate of the start point. :type y1: int :param x2: The x-coordinate of the end point. :type x2: int :param y2: The y-coordinate of the end point. :type y2: int :param color: The color of the line as an (R, G, B) or (R, G, B, A) tuple. :type color: tuple[int, int, int] | tuple[int, int, int, int] .. py:method:: create_texture_rgba(w: int, h: int, data: bytes | bytearray | memoryview, pitch: int = -1) -> int Create a texture from RGBA pixel data. :param w: The width of the texture. :type w: int :param h: The height of the texture. :type h: int :param data: The pixel data in RGBA format. :type data: bytes | bytearray | memoryview :param pitch: The number of bytes per row (including padding). If -1, rows are assumed to be tightly packed. :type pitch: int :return: The ID of the created texture. :rtype: int .. py:method:: draw_texture(tex: int, x: int, y: int, w: int, h: int, angle_deg: float = 0.0) Draw a texture at the specified position and size. :param tex: The ID of the texture to draw. :type tex: int :param x: The x-coordinate of the top-left corner where the texture should be drawn. :type x: int :param y: The y-coordinate of the top-left corner where the texture should be drawn. :type y: int :param w: The width to draw the texture. :type w: int :param h: The height to draw the texture. :type h: int :param angle_deg: Clockwise rotation angle in degrees around texture center. :type angle_deg: float .. py:method:: destroy_texture(tex: int) -> None Destroy a texture, freeing associated resources. :param tex: The ID of the texture to destroy. :type tex: int .. py:method:: draw_texture_tiled_y(tex_id: int, x: int, y: int, w: int, h: int) Draw a texture repeated vertically to fill (w,h). Assumes you can resolve tex_id -> pygame.Surface, and supports scaling width. .. py:method:: draw_circle(x: int, y: int, radius: int, color=(255, 255, 255)) Draw a filled circle. :param x: Center x :param y: Center y :param radius: Radius in pixels :param color: (R,G,B) or (R,G,B,A) .. py:method:: draw_poly(points: list[tuple[int, int]], color=(255, 255, 255), filled: bool = True) Draw a polygon defined by a list of points. :param points: A list of (x, y) tuples defining the vertices of the polygon. :type points: list[tuple[int, int]] :param color: The color of the polygon as an (R, G, B) or (R, G, B, A) tuple. :type color: tuple[int, int, int] | tuple[int, int, int, int] :param filled: Whether to fill the polygon (True) or draw only the outline (False). :type filled: bool