simvx.graphics.draw2d¶
Immediate-mode 2D drawing API for Vulkan backend.
Canonical API — one entry point per primitive, keyword-only colour/filled/thickness:
Draw2D.draw_rect(pos, size, *, colour=None, filled=False, thickness=1.0)
Draw2D.draw_line(a, b, *, colour=None, thickness=1.0)
Draw2D.draw_circle(center, radius, *, colour=None, filled=False, segments=32)
Draw2D.draw_text(text, pos, *, colour=None, scale=1.0)
Collects per-frame geometry into CPU buffers; Draw2DPass uploads and renders.
Module Contents¶
Classes¶
Vulkan-backed immediate-mode 2D drawing API. |
Data¶
API¶
- simvx.graphics.draw2d.__all__¶
[‘Draw2D’, ‘UI_VERTEX_DTYPE’]
- class simvx.graphics.draw2d.Draw2D[source]¶
Bases:
simvx.graphics.draw2d_transform.Draw2DTransformMixin,simvx.graphics.draw2d_text.Draw2DTextMixin,simvx.graphics.draw2d_texture.Draw2DTextureMixin,simvx.graphics.draw2d_batch.Draw2DBatchMixinVulkan-backed immediate-mode 2D drawing API.
- classmethod draw_rect(pos, size, *, colour=None, filled=False, thickness=1.0) None[source]¶
Draw a rectangle. filled=False draws an outline, filled=True fills the rect.
- classmethod draw_lines(points, closed=True, colour=None)[source]¶
Draw a polyline (optionally closed) through the given points.
- classmethod draw_circle(center, radius, *, colour=None, filled=False, segments=32) None[source]¶
Draw a circle. filled=False draws an outline, filled=True fills a triangle fan.
- classmethod fill_triangle(x1, y1, x2, y2, x3, y3, *, colour=None)[source]¶
Emit a single filled triangle.
- classmethod fill_quad(x1, y1, x2, y2, x3, y3, x4, y4, *, colour=None)[source]¶
Emit a filled quad from four arbitrary corners (two triangles).
- classmethod draw_thick_line(x1, y1, x2, y2, width=2.0, *, colour=None)[source]¶
Draw a thick line as a filled quad using perpendicular offsets.
- classmethod draw_polygon(vertices, *, colour=None)[source]¶
Fill a convex polygon using a triangle fan from the first vertex.
- classmethod fill_rect_gradient(x, y, w, h, colour_top, colour_bottom)[source]¶
Fill rect with vertical gradient (top colour -> bottom colour).
- classmethod push_transform(a, b, c, d, tx, ty)¶
- classmethod pop_transform()¶
- classmethod push_identity()¶
- classmethod set_font(path: str | None = None, size: int = 48) None¶
- classmethod draw_text(text, pos, *, colour=None, scale=1.0)¶
- classmethod text_width(text, scale=1)¶
- classmethod register_texture(png_data: bytes) int¶
- classmethod register_texture_with_id(texture_id: int, png_data: bytes) None¶
- classmethod draw_texture(texture_id: int, x: float, y: float, w: float, h: float, colour: tuple[float, ...] | None = None, rotation: float = 0.0)¶
- 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)¶
- 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)¶
- classmethod push_clip(x: int, y: int, w: int, h: int)¶
- classmethod pop_clip()¶
- classmethod new_layer()¶
- classmethod reset_clip()¶