simvx.core.port_helpers.procedural_textures¶
Procedural NumPy textures for game ports: checkered, grids, sprite atlases, glyphs.
All functions return RGBA uint8 ndarrays of shape (H, W, 4) that can be
passed directly to Sprite2D.texture (or any source TextureManager.resolve
accepts). Pure NumPy, no GPU, no PIL: handy for prototyping ports before art
lands, or for procedural game art.
The colour palette format is (R, G, B, A) uint8 tuples or 0..255 ints.
Module Contents¶
Functions¶
|
|
Classic two-tone checkerboard. Vectorised: no Python-level loops. |
|
A grid of |
|
Stitch per-frame RGBA ndarrays into an atlas. |
|
Rasterise a single character to a |
|
Rasterise a short string as a horizontal strip of glyphs. |
Data¶
API¶
- simvx.core.port_helpers.procedural_textures.RGBA¶
None
- simvx.core.port_helpers.procedural_textures.solid(size: int | tuple[int, int], colour: simvx.core.port_helpers.procedural_textures.RGBA | tuple[int, int, int]) numpy.ndarray[source]¶
size × size(or(W, H)) RGBA texture filled with one colour.
- simvx.core.port_helpers.procedural_textures.checkerboard(size: int | tuple[int, int] = 64, cell: int = 8, light: simvx.core.port_helpers.procedural_textures.RGBA | tuple[int, int, int] = (220, 220, 220), dark: simvx.core.port_helpers.procedural_textures.RGBA | tuple[int, int, int] = (60, 60, 60)) numpy.ndarray[source]¶
Classic two-tone checkerboard. Vectorised: no Python-level loops.
- simvx.core.port_helpers.procedural_textures.packed_grid(cell_size: int, columns: int, rows: int, colours: collections.abc.Sequence[simvx.core.port_helpers.procedural_textures.RGBA | tuple[int, int, int]], *, line_colour: simvx.core.port_helpers.procedural_textures.RGBA | tuple[int, int, int] | None = None, line_width: int = 0) numpy.ndarray[source]¶
A grid of
columns × rowssolid cells, eachcell_sizesquare.colourscycles when shorter thancolumns * rows.line_colouroptionally draws separator lines ofline_widthpixels between cells.Useful for ad-hoc tile atlases, palette swatches, or pip displays.
- simvx.core.port_helpers.procedural_textures.sprite_atlas(frames: collections.abc.Iterable[numpy.ndarray], *, columns: int | None = None) tuple[numpy.ndarray, int, int][source]¶
Stitch per-frame RGBA ndarrays into an atlas.
Returns
(atlas, columns, rows): the atlas is shaped(rows * fh, columns * fw, 4). Frames must share dimensions. IfcolumnsisNone, a near-square grid is chosen (columns = ceil(sqrt(N))).
- simvx.core.port_helpers.procedural_textures.glyph(ch: str, *, scale: int = 1, colour: simvx.core.port_helpers.procedural_textures.RGBA | tuple[int, int, int] = (255, 255, 255), background: simvx.core.port_helpers.procedural_textures.RGBA = (0, 0, 0, 0)) numpy.ndarray[source]¶
Rasterise a single character to a
(7·scale, 5·scale, 4)RGBA bitmap.Unsupported characters return a blank glyph (background-filled). Lower-case letters fall through to upper-case.
- simvx.core.port_helpers.procedural_textures.text_strip(text: str, *, scale: int = 2, colour: simvx.core.port_helpers.procedural_textures.RGBA | tuple[int, int, int] = (255, 255, 255), spacing: int = 1, background: simvx.core.port_helpers.procedural_textures.RGBA = (0, 0, 0, 0)) numpy.ndarray[source]¶
Rasterise a short string as a horizontal strip of glyphs.
Useful for debug HUDs / number displays where pulling in the engine’s MSDF text pass is overkill (e.g. a
Sprite2Dcarrying the player’s score).