factoriax.playground.ui.icons#
Procedural icon and texture generation for play, editor, and menu UI.
- factoriax.playground.ui.icons.build_texture_lookup(size: int) ndarray#
Build a dense texture lookup array indexed by block type.
Allows tile rendering via a single numpy advanced-index operation instead of a Python loop over every map cell.
- Parameters:
size – Block pixel size.
- Return type:
Array of shape (max_block_id + 1, size, size, 4).
- factoriax.playground.ui.icons.create_biter_texture(size: int = 32) ndarray#
Create a biter texture as a small red circle.
- Parameters:
size – Side length of the texture in pixels.
- Return type:
RGBA numpy array of shape (size, size, 4).
- factoriax.playground.ui.icons.create_default_textures(size: int = 32) dict[int, ndarray]#
Create patterned block textures without touching disk.
An ore block takes the same patch pattern as its inventory icon. The tile, the mined item, and the plate that comes from it therefore look like one family. Every other block stays solid.
- Parameters:
size – Side length of each texture in pixels.
- Return type:
Dictionary mapping BlockType values to RGBA texture arrays.
- factoriax.playground.ui.icons.create_player_start_icon(player_idx: int = 0, size: int = 32) ndarray#
Create a player start icon as a colored circle with a white X.
Used in the map editor to mark spawn positions. The circle colour comes from
PLAYER_COLORS[player_idx].- Parameters:
player_idx – Player index (determines colour).
size – Side length of the icon in pixels.
- Return type:
RGBA numpy array of shape
(size, size, 4).
- factoriax.playground.ui.icons.create_player_texture(direction: int = Direction.DOWN, player_idx: int = 0, is_selected: bool = True, size: int = 32) ndarray#
Create a player texture with directional indicator.
The player is rendered as a circle with a small triangle indicating the direction they are facing. Different players have different colors, and the selected player has a highlight ring.
- Parameters:
direction – The direction the player is facing (Action enum value)
player_idx – Index of the player (determines color)
is_selected – Whether this player is currently selected
size – Side length of the texture in pixels
- Return type:
RGBA numpy array of shape (size, size, 4)
- factoriax.playground.ui.icons.get_textures(size: int = 32) dict[int, ndarray]#
Return the block textures at one size.
The function reads the texture files. If a file is absent, it builds the default pattern instead.
The cache holds the textures of each size, so the process reads the disk and resizes one time only for each size.
- Parameters:
size – Required texture side length in pixels.
- Return type:
Dictionary mapping BlockType values to RGBA texture arrays
- factoriax.playground.ui.icons.load_all_textures() dict[int, ndarray]#
Load all block textures into a dictionary.
- Return type:
Dictionary mapping BlockType values to RGBA texture arrays.
- factoriax.playground.ui.icons.load_texture(name: str) ndarray#
Load a texture from the assets directory.
- Parameters:
name – Name of the texture file (without extension).
- Return type:
RGBA numpy array of shape (BLOCK_PIXEL_SIZE, BLOCK_PIXEL_SIZE, 4).
- Raises:
FileNotFoundError – If the texture file does not exist.
- factoriax.playground.ui.icons.render_item_icon(item_type: int, size: int, direction: int | None = None) ndarray#
Render a square RGBA icon for an item type.
This is the single source of truth for how an item looks visually. Four surfaces draw an item: the inventory panels, the hotbar, the editor toolbar, and the menu screens. Each one calls this function, so one item always looks the same.
Each item category has a distinct visual language:
Ores: irregular darker blobs on a rough base (silicon adds crystalline sparkles).
Plates: diagonal shine band on a uniform base. Wafer adds concentric arcs to suggest a disc.
Intermediate items: a shape that hints at the object. Examples are a wire helix, circuit traces, motor cylinder, sensor lens, frame I-beam, flask, rocket silhouette.
Machines: a pattern inside the body. A miner gets a bore, a pallet gets slats, and a belt gets edge stripes. Every machine also takes a highlight at the top left, and a shadow at the bottom right. A placed machine therefore looks like a built object.
When
directionisNone, for example in a menu with no placement context, directional indicators point right by default.- Parameters:
item_type –
ItemTypeinteger value.size – Side length of the returned square in pixels.
direction – Optional
Directionfor directional items. Ignored for non-directional items.
- Return type:
RGBA uint8 array of shape
(size, size, 4).