pyhexlib.render module
- class pyhexlib.render.HexGridRenderer(layers, radius=50, bg_color=(100, 100, 100), bg_image=None, assets=None, visible_size=None, origin=None)[source]
Bases:
object- Parameters:
layers (HexGridManager)
radius (int)
bg_color (Tuple[int, int, int] | Tuple[int, int, int, int] | pygame.Color)
bg_image (pygame.Surface)
assets (Assets)
visible_size (Size)
origin (Hexagon)
- __repr__()[source]
Return a concise developer representation showing: - hex size, surface size, background color, - grids container name, number of cached hexes, offsets, and whether assets are set.
- Return type:
str
- get_renderer(layer)[source]
- Parameters:
layer (HexGridLayer)
- get_surface(layer)[source]
Get the rendered surface for a given layer, using caching to optimize performance.
- Parameters:
layer (HexGridLayer)
- Return type:
pygame.Surface
- is_layer_visible(grid_name)[source]
Check visibility of a named grid in the grid’s container.
- Parameters:
grid_name (str)
- Return type:
bool
- scroll(delta_r, delta_c)[source]
Scroll the grid by changing the origin hex’s row and column coordinates.
- set_layer_visible(grid_name, visible)[source]
Set visibility of a named grid in the grid’s container.
- Parameters:
grid_name (str)
visible (bool)
- Return type:
None
- set_origin(origin)[source]
Set the origin hex for rendering, which determines the clipping bounds.
- Parameters:
origin (Hexagon)
- set_renderer(layer_type, render_fn)[source]
Register a custom rendering function for a specific layer type.
- Parameters:
layer_type (type | str)
- Return type:
None