hexagonal_grid 1.0.2 copy "hexagonal_grid: ^1.0.2" to clipboard
hexagonal_grid: ^1.0.2 copied to clipboard

outdated

A hexagonal grid library for Dart 2 that uses axial coordinates and contains algorithms to build hex layouts

example/example.dart

import 'dart:math';

import 'package:hexagonal_grid/hexagonal_grid.dart';

class Example {
  void createOriginHexWithLayout() {
    //Origin hex where q = 0, and r = 0 (axial coordinates)
    final Hex originHex = Hex(0, 0);

    //Arbitrary sizes and layout origins to help construct the HexLayout
    final Point size = Point(2, 2);
    final Point hexLayoutOrigin = Point(5, 5);

    //Create a flat HexLayout
    final HexLayout hexLayout = HexLayout.orientFlat(size, hexLayoutOrigin);

    //Transpose the axial coordinate Hex onto the HexLayout to get a pixel
    // representation of that Hex
    final Point hexToPixel = originHex.toPixel(hexLayout);
  }

  void createNeighbors() {
    //Origin hex where q = 0, and r = 0 (axial coordinates)
    final Hex originHex = Hex(0, 0);

    //Arbitrary sizes and layout origins to help construct the HexLayout
    for (int d = 0; d < Hex.directions.length; d++) {
      Hex neighborHex = originHex.neighbor(d);
      print(neighborHex);
    }
  }
}
4
likes
0
pub points
22%
popularity

Publisher

unverified uploader

A hexagonal grid library for Dart 2 that uses axial coordinates and contains algorithms to build hex layouts

Repository (GitLab)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on hexagonal_grid