16 releases (2 stable)

Uses old Rust 2015

1.1.0 Aug 16, 2021
1.0.0 Oct 29, 2020
0.3.0 Oct 29, 2020
0.2.0 Jan 30, 2018
0.0.3 Dec 9, 2014

#407 in Algorithms

Download history 73/week @ 2024-02-25 43/week @ 2024-03-03 59/week @ 2024-03-10 51/week @ 2024-03-17 37/week @ 2024-03-24 112/week @ 2024-03-31 33/week @ 2024-04-07 47/week @ 2024-04-14 47/week @ 2024-04-21 46/week @ 2024-04-28 49/week @ 2024-05-05 42/week @ 2024-05-12 45/week @ 2024-05-19 37/week @ 2024-05-26 42/week @ 2024-06-02 21/week @ 2024-06-09

150 downloads per month
Used in 3 crates

MIT license

52KB
1K SLoC

hex2d

Build Status Gitter Chat
Documentation

Introduction

Library for working with 2d hex map systems.

A lot of ideas taken from redbloggames hexagon page

Read Documentation for details.

See issues for TODO and BUGs.

You might be interested in additional functionality provided by hex2d-dpcext-rs library.

Coordinate system

Pointy-topped:

          /\
        /    \
       |      |
       |      |
        \    /
          \/

          -z
+y     YZ  |  XZ     +x
 ---       |       ---
    ---    |    ---
       --- | ---
  YX      -x-    XY
       --- | ---
    ---    |    ---
 ---   ZX  |  ZY   ---
-x         |          -y
          +z

Flat-topped:

         ____
        /    \
       /      \
       \      /
        \____/

     +y       -z
      \       /
       \ YZ  /
    YX  \   /  XZ
         \ /
-x--------x--------+x
         / \
    ZX  /   \ XY
       /  ZY \
      /       \
     +z       -y

Building

cargo build

Verification Recommendation

To help with the maintaince, the ownership of this crate is potentially shared between multiple developers. It is recommended to always use cargo-crev to verify the trustworthiness of each of your dependencies, including this one.

Dependencies

~390–630KB
~13K SLoC