factoriax.playground.ui.primitives#
Core UI primitives: click regions, hit testing, and panel drawing.
- class factoriax.playground.ui.primitives.ClickRegion(x: int, y: int, w: int, h: int, action: str, param: int)#
Represents a clickable rectangular area in the UI.
Coordinates are in base render resolution (before window scaling).
- factoriax.playground.ui.primitives.draw_panel(overlay: ndarray, x: int, y: int, w: int, h: int, *, bg: tuple[int, int, int, int] | None = None, border: tuple[int, int, int, int] | None = None, border_px: int | None = None) None#
Draw a rectangular panel: solid background with a uniform border.
Modifies overlay in place.
- Parameters:
overlay – Destination RGBA array of shape (H, W, 4).
x – Left column of the panel.
y – Top row of the panel.
w – Panel width in pixels.
h – Panel height in pixels.
bg – Background RGBA colour.
border – Border RGBA colour.
border_px – Border thickness in pixels.
*
int
None (int] |)
- factoriax.playground.ui.primitives.hit_test_regions(regions: list[ClickRegion], x: int, y: int) ClickRegion | None#
Find the first click region containing the given point.
- Parameters:
regions – List of click regions to test.
x – X coordinate in base resolution.
y – Y coordinate in base resolution.
- Return type:
The first matching ClickRegion, or None if no hit.