hex_grid 0.2.1

A library to easily work with 2d hex grids of arbitrary shapes
Documentation
  • Coverage
  • 10.34%
    3 out of 29 items documented0 out of 10 items with examples
  • Size
  • Source code size: 13.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.96 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • fuchsnj/hex_grid
    1 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • fuchsnj

Hex Grid

Build Status crates.io

Documentation

A library to easily work with 2d hex grids of arbitrary shapes. This library currently only supports "Pointy Top" hexagons.

Usage

Add this to your Cargo.toml:

[dependencies]
hex_grid = "*"

and this to your crate root:

extern crate hex_grid;

Quick Start

use hex_grid::*;
use std::collections::HashMap;

struct CustomData{
    //..whatever data you want associated with each tile
}

//empty grid
let mut grid: HashMap<Coordinate, CustomData> = HashMap::new();

//fill the grid with tiles in a hexagon shape of size 3
let coords = CENTER + Offset::fill_hex(3);
for coord in coords {
    let data:CustomData = //...
    grid.insert(coord, data);
}

//get the tile that is to the right 2 tiles from the center tile
let tile:Option<CustomData> = grid.get(CENTER + RIGHT*2);