pyhexlib.layers module
- class pyhexlib.layers.AxialCoordinateHexGridLayer(grid_id, hexagons=None, visible=False, comment=None)[source]
Bases:
HexGridLayer- Parameters:
grid_id (str)
hexagons (HexagonalGrid)
visible (bool)
comment (str)
- class pyhexlib.layers.Border(rc, direction)[source]
Bases:
objectA border between two Hexagons, or the border of a HexGrid.
- class pyhexlib.layers.CoordinateGridLayer(grid_id, visible=False, font_family='Arial', font_color=(0, 0, 0), font_size=12, comment=None)[source]
Bases:
TextGridLayer- Parameters:
grid_id (str)
font_color (Tuple[int, int, int] | Tuple[int, int, int, int] | pygame.Color)
font_size (int)
- class pyhexlib.layers.FillGridLayer(grid_id, hexagons=None, visible=True, default_color=None, comment=None)[source]
Bases:
StyledGridLayerA grid that stores fill colors for each hexagon.
- Parameters:
default_color (Tuple[int, int, int] | Tuple[int, int, int, int] | pygame.Color)
- class pyhexlib.layers.HexGridLayer(grid_id, hexagons=None, visible=True, comment=None)[source]
Bases:
ABCAn abstract base class for all hexagon grids. It keeps track of the hexagons in the grid and whether the grid is visible.
- Parameters:
grid_id (str)
hexagons (HexagonalGrid)
visible (bool)
comment (str)
- class pyhexlib.layers.HexGridManager(hexagons)[source]
Bases:
object- Parameters:
hexagons (HexagonalGrid)
- add_layer(grid)[source]
- Parameters:
grid (HexGridLayer)
- Return type:
- get_hexagons(clipping=None)[source]
Return a HexagonalGrid containing only the hex coordinates inside a clipping.
- Parameters:
clipping (None | tuple[int,int,int,int] | object) – Either
None(returns the full grid) or a 4-tuple(r_min, c_min, r_max, c_max)specifying top-left and bottom-right coordinates (inclusive). The method also accepts an object that exposestop_leftandbottom_rightattributes each being an(r, c)tuple.- Return type:
The bounds are inclusive. The method normalizes min/max for each axis so the order of coordinates does not matter.
- get_layer(grid_id)[source]
- Parameters:
grid_id (str)
- Return type:
HexGridLayer | None
- property height: int
- property visible_layers: List[HexGridLayer]
- property width: int
- class pyhexlib.layers.ImageGridLayer(grid_id, hexagons=None, visible=True, comment=None)[source]
Bases:
HexGridLayer- Parameters:
grid_id (str)
visible (bool)
- class pyhexlib.layers.OutlineGridLayer(grid_id, hexagons=None, visible=True, default_color=None, default_width=1, comment=None)[source]
Bases:
StyledGridLayerA grid that stores outline colors and widths for each hexagon.
- Parameters:
default_color (Tuple[int, int, int] | Tuple[int, int, int, int] | pygame.Color)
- class pyhexlib.layers.PathGridLayer(grid_id, hexagons=None, visible=True, color=(0, 0, 0), width=5, comment=None)[source]
Bases:
HexGridLayer- Parameters:
grid_id (str)
hexagons (HexagonalGrid)
color (Tuple[int, int, int] | Tuple[int, int, int, int] | pygame.Color)
width (int)
comment (str)
- class pyhexlib.layers.SimpleImageGridLayer(grid_id, hexagons=None, visible=True, comment=None)[source]
Bases:
ImageGridLayer- Parameters:
grid_id (str)
visible (bool)
- class pyhexlib.layers.StyledGridLayer(grid_id, hexagons, visible=True, default_color=None, default_width=1, comment=None)[source]
Bases:
HexGridLayerA grid that stores styles (color and width) for each hexagon. 0 width means fill, >0 means outline with given width.
- Parameters:
grid_id (str)
hexagons (List[Hexagon])
visible (bool)
comment (str)
- property default_color: Tuple[int, int, int] | Tuple[int, int, int, int] | pygame.Color | None
- property default_width: Tuple[int, int, int] | Tuple[int, int, int, int] | pygame.Color | None
- class pyhexlib.layers.TextGridLayer(grid_id, hexagons=None, font_family='Arial', font_color=(0, 0, 0), font_size=12, visible=True, comment=None)[source]
Bases:
ValueGridLayer- Parameters:
grid_id (str)
hexagons (HexagonalGrid)
font_color (Tuple[int, int, int] | Tuple[int, int, int, int] | pygame.Color)
font_size (int)
comment (str)
- class pyhexlib.layers.Token(token_id, image=None, rc=None)[source]
Bases:
ABC- Parameters:
token_id (int | str)
image (pygame.Surface)
rc (Hexagon)
- __repr__()[source]
Return a concise developer representation for DirectionToken.
Shows the token id, grid coordinate (rc), the direction name, the computed angle (degrees) and whether an image surface is present.
- Return type:
str
- abstract property angle: pygame.Surface
- property image
- class pyhexlib.layers.TokenGridLayer(grid_id, hexagons=None, visible=True, comment=None)[source]
Bases:
ImageGridLayer- Parameters:
grid_id (str)
visible (bool)
comment (str)
- class pyhexlib.layers.ValueGridLayer(grid_id, hexagons=None, default_value=None, visible=False, comment=None)[source]
Bases:
HexGridLayer- Parameters:
grid_id (str)
hexagons (HexagonalGrid)
comment (str)