Skip to content

1. Getting started

DigitalSmile edited this page Oct 20, 2022 · 1 revision

Add dependency to your project. Latest version can be found at the jitpack badge.

Gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    implementation 'com.github.DigitalSmile:hexagon:{version}'
}

Maven:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
...
<dependency>
    <groupId>com.github.DigitalSmile</groupId>
    <artifactId>hexagon</artifactId>
    <version>{version}</version>
</dependency>

Use a HexagonGridBuilder to create a grid or use Hexagon and Operations classes directly:

var hexagonGrid = new HexagonGrid.HexagonGridBuilder<>()
                        .shape(new HexagonalShape(5), Orientation.FLAT) // hexagonal shape with radius of 5 hexagons and flat orientation
                        .hexagonWidth(150)                              // width of hexagon in physical units
                        .build();
hexagonGrid.generateHexagons();
var hexagonList = hexagonGrid.getHexagons(); // returns all generated hexagons
var lineHexagonList = HexagonOperations.hexagonLinePath(new Hexagon(0,0,0), new Hexagon(0, -3, 3)); // returns hexagons, that are in line between two hexagons

Clone this wiki locally