simvx.graphics.draw2d_texture¶
Textured quad drawing for Draw2D.
Handles texture registration, textured quad emission, and 9-patch rendering.
Module Contents¶
Classes¶
Mixin providing textured quad drawing for Draw2D. |
API¶
- class simvx.graphics.draw2d_texture.Draw2DTextureMixin[source]¶
Mixin providing textured quad drawing for Draw2D.
- classmethod register_texture(png_data: bytes) int[source]¶
Register a CPU-side texture for streaming. Returns a texture ID.
Use this in CPU-only mode (web editor) where there’s no GPU TextureManager. The returned ID can be passed to
draw_texture()/draw_texture_region().
- classmethod register_texture_with_id(texture_id: int, png_data: bytes) None[source]¶
Register PNG data for a known texture ID (for streaming sync).
- classmethod draw_texture(texture_id: int, x: float, y: float, w: float, h: float, colour: tuple[float, ...] | None = None, rotation: float = 0.0)[source]¶
Draw a textured quad at (x, y) with size (w, h).
Args: texture_id: Bindless texture index from TextureManager. x, y: Top-left position in screen pixels. w, h: Width and height in screen pixels. colour: Optional RGBA tint (0.0-1.0 floats). Default white. rotation: Rotation in radians around the quad center.
- classmethod draw_texture_region(texture_id: int, x: float, y: float, w: float, h: float, u0: float = 0.0, v0: float = 0.0, u1: float = 1.0, v1: float = 1.0, colour: tuple[float, ...] | None = None, rotation: float = 0.0)[source]¶
Draw a sub-rectangle of a texture as a quad.
Args: texture_id: Bindless texture index. x, y: Top-left position in screen pixels. w, h: Width and height in screen pixels. u0, v0, u1, v1: UV coordinates for the source region (0-1). colour: Optional RGBA tint (0.0-1.0 floats). Default white. rotation: Rotation in radians around the quad center.
- classmethod draw_nine_patch(texture_id: int, x: float, y: float, w: float, h: float, tex_w: float, tex_h: float, margin_left: float = 0.0, margin_right: float = 0.0, margin_top: float = 0.0, margin_bottom: float = 0.0, draw_centre: bool = True, colour: tuple[float, ...] | None = None)[source]¶
Draw a 9-slice textured rectangle.
Divides the source texture into 9 regions using the margin values. Corners remain fixed-size, edges stretch in one direction, and the centre fills the remaining space. This is the standard 9-patch / 9-slice technique for scalable UI panels, buttons, and speech bubbles.
Args: texture_id: Bindless texture index from TextureManager. x, y: Top-left position in screen pixels. w, h: Display width and height in screen pixels. tex_w, tex_h: Source texture dimensions in pixels. margin_left, margin_right: Left/right border widths (pixels in source texture). margin_top, margin_bottom: Top/bottom border heights (pixels in source texture). draw_centre: Whether to draw the centre region (default True). colour: Optional RGBA tint (0.0-1.0 floats). Default white.