pyhexlib.viewport module

class pyhexlib.viewport.HexGridViewport(hexagonal_grid, radius, visible_size, origin, offset=pygame.Vector2)[source]

Bases: object

Parameters:
  • hexagonal_grid (HexagonalGrid)

  • radius (int)

  • visible_size (tuple[int, int])

  • origin (Hexagon)

  • offset (pygame.Vector2)

adjust_bounds(bounds)[source]
Parameters:

bounds (Bounds)

Return type:

Bounds

center(rc)[source]

Return cached pixel center for hex coordinate rc (r,c).

Parameters:

rc (Hexagon)

Return type:

pygame.Vector2

edges(rc)[source]

Return cached list of six corner points for hex key h (r,c).

Parameters:

rc (Hexagon)

Return type:

list[pygame.Vector2]

move_by(rows=0, cols=0)[source]

Move the viewport by a given amount.

Parameters:
  • rows (int)

  • cols (int)

Return type:

None

move_to(origin)[source]

Move the viewport to a new origin hex.

Parameters:

origin (Hexagon)

Return type:

None

property origin: Hexagon

Return the current origin hex for rendering.

class pyhexlib.viewport.Hexagons(hexagons)[source]

Bases: object

Parameters:

hexagons (Dict[Any, Any])

center(rc)[source]

Return cached pixel center for hex coordinate rc (r,c).

Parameters:

rc (Hexagon)

Return type:

pygame.Vector2

edges(rc)[source]

Return cached list of six corner points for hex key h (r,c).

Parameters:

rc (Hexagon)

Return type:

list[pygame.Vector2]

get(key, default=None)[source]
items()[source]
keys()[source]
values()[source]
class pyhexlib.viewport.Viewport(bounds, outer_bounds)[source]

Bases: Bounds

Parameters: