Crate aglet

source ·
Expand description

Another Grid Library Except Terrible

This is a successor to my old crate cogs_gamedev’s grids module. It adds opinionated integer-based coordinates and directions, along with some other useful things:

  • Iterators over areas, edges of areas, and lines
  • Grid<T>, which is like a HashMap<Coord, T> but faster

Also supports serde, under the default feature serde.

Structs

  • Represents a set of flags of some type T. T must have the #[bitflags] attribute applied.
  • Unsigned-int coordinates
  • Signed-int coordinates
  • Like a HashMap<Coord, T> but faster. Each grid point might store something.
  • Owning iterator over the filled slots in a Grid.
  • Borrowing iterator over the filled slots in a Grid.
  • Mutably borrowing iterator over the filled slots in a Grid.
  • Iterates over coordinates on a line using Bresenham’s algorithm.

Enums

  • Four-way directions.
  • Eight-way directions.
  • Nine-way directions: 8 compass points plus center.
  • Where to stop the iteration of the line.
  • 2-way rotations: clockwise or counterclockwise. These don’t indicate any specific angle by themselves, only in relation to something.

Traits

  • A trait automatically implemented by #[bitflags] to make the enum a valid type parameter for BitFlags<T>.

Type Aliases