endgame_grid

Crates.ioendgame_grid
lib.rsendgame_grid
version0.2.0
created_at2025-06-29 20:15:19.381791+00
updated_at2025-09-06 21:24:54.794019+00
descriptionA library for representing regular grids.
homepage
repositoryhttps://github.com/gawashburn/endgame
max_upload_size
id1731087
size178,735
(gawashburn)

documentation

README

Endgame Grid

License: MIT Crates.io version

The endgame_grid crate provides functionality for working grid systems. It currently has support for square, hexagonal, and triangular grids.

For example of the functionality this crate provides, see the online grid demo.

Future work

  • Possibly add support for pointy top hexagonal grids, instead of just flat top. While this might be a useful convenience in some cases, in practice users of the library could just rotate their grids by 90 degrees when displaying them.
  • Add support for Rust's Step trait once it is stabilized.
  • The path algorithm for square grids is counterintuitively more complex than that required for hexagonal grids. Is there a better rounding strategy that would resolve the ambiguity when the linear interpolated values pass through grid vertices?
  • The path algorithm for triangular grids currently is relatively expensive, as it relies on a conversion to screen space to determine the current error. Additionally, in some cases it will produce correct paths that are visually suboptimal. Like the square grid path algorithm, this tends to happen when interpolated values pass through grid vertices.
  • The algorithms for tessellating rectangles with hexagonal and triangular grids are a bit complex and could potentially be optimized further. If nothing else, with some additional effort it should be possible to avoid the need to check intersection with the rectangle for obviously interior grid cells. are currently somewhat simplistic. There is likely room for improvement.
  • Currenly, the support for Shape and ShapeContainer is relatively limited.
  • At present the only implementations of the Shape and ShapeContainer traits is via HashShape and HashShapeContainer. It should be possible to provide implementations optimized for specific grid types.
  • On triangular grid, a triangle will touch the vertex of nine other triangles. Currently, the vertex directions for a triangle will only allow for traversing to three of these. The endgame_direction crate only supports the usual cardinal and ordinal directions, which is insufficient to provide directions for all nine triangles. One solution would be to extend endgame_direction to also provide the secondary intercardinal directions (West-northwest, etc.).
  • At present the focus in endgame_grid has been on grid cells. It ought to be possible extend it with better support for working with grid vertices and edges.
  • The trait interfaces aim to be quite general, so it should be possible to add support for more exotic grids, for example, perhaps octagons and squares.
Commit count: 27

cargo fmt