https://github.com/njlr/solid-hex
A simple hexagon library using cube-coordinates ⬡
https://github.com/njlr/solid-hex
hexagon hexagonal-grid-library javascript
Last synced: 3 months ago
JSON representation
A simple hexagon library using cube-coordinates ⬡
- Host: GitHub
- URL: https://github.com/njlr/solid-hex
- Owner: njlr
- License: mit
- Created: 2017-12-25T07:32:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T10:22:59.000Z (over 3 years ago)
- Last Synced: 2025-07-09T03:11:51.975Z (12 months ago)
- Topics: hexagon, hexagonal-grid-library, javascript
- Language: JavaScript
- Size: 949 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - njlr/solid-hex - A simple hexagon library using cube-coordinates ⬡ (javascript)
README
# solid-hex
A simple hexagon library using cube-coordinates. ⬡
This package is based on code from https://www.redblobgames.com/grids/hexagons/.
## Install
```bash=
yarn add solid-hex
```
## Usage
```javascript=
import * as hex from 'solid-hex';
const a = hex.hex(2, 3);
const b = hex.scale(a, 10);
const c = hex.lerp(a, b, 0.5);
// etc...
```
This library is designed to work best with the [pipeline operator](https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-pipeline-operator):
```javascript=
import * as Hex from 'solid-hex';
const a = hex.hex(2, 3)
|> hex.scale(10)
|> hex.lerp(hex.hex(1, 2), 0.5))
// etc...
```