midgard-hex-grid 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +102 -1
  2. package/demo/demo-minimal.ts +531 -0
  3. package/demo/demo-theory.ts +1679 -0
  4. package/demo/index.html +11 -0
  5. package/demo/minimal.html +11 -0
  6. package/demo/package-lock.json +1162 -0
  7. package/demo/package.json +11 -0
  8. package/demo/vite.config.ts +9 -0
  9. package/dist/coordinate-layer.d.ts +1 -11
  10. package/dist/coordinate-layer.d.ts.map +1 -1
  11. package/dist/coordinate-layer.js +5 -5
  12. package/dist/coordinate-layer.js.map +1 -1
  13. package/dist/coordinate-positioner.d.ts +1 -17
  14. package/dist/coordinate-positioner.d.ts.map +1 -1
  15. package/dist/coordinate-positioner.js +7 -7
  16. package/dist/coordinate-positioner.js.map +1 -1
  17. package/dist/coordinate-range-fill.d.ts +1 -20
  18. package/dist/coordinate-range-fill.d.ts.map +1 -1
  19. package/dist/coordinate-range-fill.js +12 -10
  20. package/dist/coordinate-range-fill.js.map +1 -1
  21. package/dist/coordinate-range.d.ts +16 -7
  22. package/dist/coordinate-range.d.ts.map +1 -1
  23. package/dist/coordinate-range.js +30 -13
  24. package/dist/coordinate-range.js.map +1 -1
  25. package/dist/geometry.d.ts +1 -25
  26. package/dist/geometry.d.ts.map +1 -1
  27. package/dist/geometry.js +7 -7
  28. package/dist/geometry.js.map +1 -1
  29. package/dist/h-g-bounds.d.ts +8 -5
  30. package/dist/h-g-bounds.d.ts.map +1 -1
  31. package/dist/h-g-bounds.js +12 -10
  32. package/dist/h-g-bounds.js.map +1 -1
  33. package/dist/h-g-hexagon.d.ts +21 -7
  34. package/dist/h-g-hexagon.d.ts.map +1 -1
  35. package/dist/h-g-hexagon.js +34 -12
  36. package/dist/h-g-hexagon.js.map +1 -1
  37. package/dist/hex-grid.d.ts +5 -1
  38. package/dist/hex-grid.d.ts.map +1 -1
  39. package/dist/hex-grid.js +32 -15
  40. package/dist/hex-grid.js.map +1 -1
  41. package/dist/neighbours.d.ts +1 -23
  42. package/dist/neighbours.d.ts.map +1 -1
  43. package/dist/neighbours.js +7 -7
  44. package/dist/neighbours.js.map +1 -1
  45. package/docs/images/minimal-x.png +0 -0
  46. package/docs/images/minimal-y.png +0 -0
  47. package/docs/images/theory-x.png +0 -0
  48. package/docs/images/theory-y.png +0 -0
  49. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import type { Coordinate } from './coordinate.js';
2
- import type { GridOrientation } from './orientation.js';
3
2
  import type { Point } from './geometry.js';
3
+ import { CoordinatePositioner } from './coordinate-positioner.js';
4
+ import { HexagonGeometry } from './geometry.js';
4
5
  /**
5
6
  * Represents one complete hexagon created from
6
7
  * a Midgard coordinate.
@@ -13,23 +14,36 @@ export type CreatedHexagon = {
13
14
  /**
14
15
  * Creates complete hexagons from Midgard coordinates.
15
16
  *
16
- * The grid orientation determines how the center position
17
- * and hexagon geometry are calculated.
17
+ * The injected positioner and geometry determine how
18
+ * the center position and hexagon points are calculated.
18
19
  */
19
20
  export declare class HexGridHexagonCreator {
20
- private readonly orientation;
21
+ #private;
21
22
  /**
22
- * Creates a new hexagon creator.
23
+ * Creates a new hexagon creator using existing
24
+ * geometric helper objects.
23
25
  *
24
- * @param orientation - The orientation of the hex grid.
26
+ * @param positioner - Calculates hexagon center positions.
27
+ * @param geometry - Calculates hexagon corner points.
25
28
  */
26
- constructor(orientation: GridOrientation);
29
+ constructor(positioner: CoordinatePositioner, geometry: HexagonGeometry);
30
+ /**
31
+ * Validates the geometric size of a hexagon.
32
+ *
33
+ * The diameter must be a positive, finite number.
34
+ * Decimal values are allowed.
35
+ *
36
+ * @param hexDiameter - The geometric size to validate.
37
+ * @throws RangeError If the diameter is not positive and finite.
38
+ */
39
+ static validateHexDiameter(hexDiameter: number): void;
27
40
  /**
28
41
  * Creates the geometry for one Midgard coordinate.
29
42
  *
30
43
  * @param coordinate - The coordinate of the hexagon.
31
44
  * @param hexDiameter - The geometric size of the hexagon.
32
45
  * @returns One complete hexagon prepared for rendering.
46
+ * @throws RangeError If the diameter is not positive and finite.
33
47
  */
34
48
  createHexagon(coordinate: Coordinate, hexDiameter: number): CreatedHexagon;
35
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"h-g-hexagon.d.ts","sourceRoot":"","sources":["../src/h-g-hexagon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAM1C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,KAAK,CAAA;IACb,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB,CAAA;AAED;;;;;GAKG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiB;IAE7C;;;;OAIG;IACH,YAAY,WAAW,EAAE,eAAe,EAEvC;IAED;;;;;;OAMG;IACH,aAAa,CACX,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,GAClB,cAAc,CAsBhB;CACF"}
1
+ {"version":3,"file":"h-g-hexagon.d.ts","sourceRoot":"","sources":["../src/h-g-hexagon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,KAAK,CAAA;IACb,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB,CAAA;AAED;;;;;GAKG;AACH,qBAAa,qBAAqB;;IAIhC;;;;;;OAMG;IACH,YACE,UAAU,EAAE,oBAAoB,EAChC,QAAQ,EAAE,eAAe,EAI1B;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,mBAAmB,CACxB,WAAW,EAAE,MAAM,GAClB,IAAI,CASN;IAED;;;;;;;OAOG;IACH,aAAa,CACX,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,GAClB,cAAc,CAqBhB;CACF"}
@@ -3,18 +3,37 @@ import { HexagonGeometry } from './geometry.js';
3
3
  /**
4
4
  * Creates complete hexagons from Midgard coordinates.
5
5
  *
6
- * The grid orientation determines how the center position
7
- * and hexagon geometry are calculated.
6
+ * The injected positioner and geometry determine how
7
+ * the center position and hexagon points are calculated.
8
8
  */
9
9
  export class HexGridHexagonCreator {
10
- orientation;
10
+ #positioner;
11
+ #geometry;
11
12
  /**
12
- * Creates a new hexagon creator.
13
+ * Creates a new hexagon creator using existing
14
+ * geometric helper objects.
13
15
  *
14
- * @param orientation - The orientation of the hex grid.
16
+ * @param positioner - Calculates hexagon center positions.
17
+ * @param geometry - Calculates hexagon corner points.
15
18
  */
16
- constructor(orientation) {
17
- this.orientation = orientation;
19
+ constructor(positioner, geometry) {
20
+ this.#positioner = positioner;
21
+ this.#geometry = geometry;
22
+ }
23
+ /**
24
+ * Validates the geometric size of a hexagon.
25
+ *
26
+ * The diameter must be a positive, finite number.
27
+ * Decimal values are allowed.
28
+ *
29
+ * @param hexDiameter - The geometric size to validate.
30
+ * @throws RangeError If the diameter is not positive and finite.
31
+ */
32
+ static validateHexDiameter(hexDiameter) {
33
+ if (!Number.isFinite(hexDiameter) ||
34
+ hexDiameter <= 0) {
35
+ throw new RangeError('Hexagon diameter must be a positive, finite number.');
36
+ }
18
37
  }
19
38
  /**
20
39
  * Creates the geometry for one Midgard coordinate.
@@ -22,14 +41,17 @@ export class HexGridHexagonCreator {
22
41
  * @param coordinate - The coordinate of the hexagon.
23
42
  * @param hexDiameter - The geometric size of the hexagon.
24
43
  * @returns One complete hexagon prepared for rendering.
44
+ * @throws RangeError If the diameter is not positive and finite.
25
45
  */
26
46
  createHexagon(coordinate, hexDiameter) {
27
- const positioner = new CoordinatePositioner(this.orientation);
28
- const center = positioner.getCenterPosition(coordinate, hexDiameter);
29
- const geometry = new HexagonGeometry(this.orientation);
30
- const points = geometry.getHexagonPoints(center, hexDiameter);
47
+ HexGridHexagonCreator.validateHexDiameter(hexDiameter);
48
+ const center = this.#positioner.getCenterPosition(coordinate, hexDiameter);
49
+ const points = this.#geometry.getHexagonPoints(center, hexDiameter);
31
50
  return {
32
- coordinate,
51
+ coordinate: {
52
+ x: coordinate.x,
53
+ y: coordinate.y
54
+ },
33
55
  center,
34
56
  points
35
57
  };
@@ -1 +1 @@
1
- {"version":3,"file":"h-g-hexagon.js","sourceRoot":"","sources":["../src/h-g-hexagon.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAY/C;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IACf,WAAW,CAAiB;IAE7C;;;;OAIG;IACH,YAAY,WAA4B;QACtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CACX,UAAsB,EACtB,WAAmB;QAEnB,MAAM,UAAU,GACd,IAAI,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAE5C,MAAM,MAAM,GAAG,UAAU,CAAC,iBAAiB,CACzC,UAAU,EACV,WAAW,CACZ,CAAA;QAED,MAAM,QAAQ,GACZ,IAAI,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAEvC,MAAM,MAAM,GAAG,QAAQ,CAAC,gBAAgB,CACtC,MAAM,EACN,WAAW,CACZ,CAAA;QAED,OAAO;YACL,UAAU;YACV,MAAM;YACN,MAAM;SACP,CAAA;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"h-g-hexagon.js","sourceRoot":"","sources":["../src/h-g-hexagon.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAY/C;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IACvB,WAAW,CAAsB;IACjC,SAAS,CAAiB;IAEnC;;;;;;OAMG;IACH,YACE,UAAgC,EAChC,QAAyB;QAEzB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;IAC3B,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,mBAAmB,CACxB,WAAmB;QAEnB,IACE,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC;YAC7B,WAAW,IAAI,CAAC,EAChB,CAAC;YACD,MAAM,IAAI,UAAU,CAClB,qDAAqD,CACtD,CAAA;QACH,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACH,aAAa,CACX,UAAsB,EACtB,WAAmB;QAEnB,qBAAqB,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAA;QAEtD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAC/C,UAAU,EACV,WAAW,CACZ,CAAA;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAC5C,MAAM,EACN,WAAW,CACZ,CAAA;QAED,OAAO;YACL,UAAU,EAAE;gBACV,CAAC,EAAE,UAAU,CAAC,CAAC;gBACf,CAAC,EAAE,UAAU,CAAC,CAAC;aAChB;YACD,MAAM;YACN,MAAM;SACP,CAAA;IACH,CAAC;CACF"}
@@ -47,7 +47,7 @@ export type LayeredHexagon = Hexagon & {
47
47
  * Represents a Midgard hex grid with a specific orientation.
48
48
  */
49
49
  export declare class HexGrid {
50
- private readonly orientation;
50
+ #private;
51
51
  /**
52
52
  * Creates a new Midgard hex grid.
53
53
  *
@@ -70,6 +70,7 @@ export declare class HexGrid {
70
70
  *
71
71
  * @param options - The hexagon size and skeleton dimensions.
72
72
  * @returns All layered hexagons belonging to the complete grid.
73
+ * @throws RangeError If the hexagon diameter is invalid.
73
74
  */
74
75
  createGrid(options: HexGridOptions): LayeredHexagon[];
75
76
  /**
@@ -100,6 +101,7 @@ export declare class HexGrid {
100
101
  * @param coordinate - The Midgard coordinate to position.
101
102
  * @param size - The width or height of one hexagon.
102
103
  * @returns The calculated center point.
104
+ * @throws RangeError If the size is not positive and finite.
103
105
  */
104
106
  getCenterPosition(coordinate: Coordinate, size: number): Point;
105
107
  /**
@@ -109,6 +111,7 @@ export declare class HexGrid {
109
111
  * @param center - The center point of the hexagon.
110
112
  * @param size - The dimension used to calculate the hexagon.
111
113
  * @returns The six corner points of the hexagon.
114
+ * @throws RangeError If the size is not positive and finite.
112
115
  */
113
116
  getHexagonPoints(center: Point, size: number): Point[];
114
117
  /**
@@ -122,6 +125,7 @@ export declare class HexGrid {
122
125
  * @param coordinates - The coordinates whose bounds should be calculated.
123
126
  * @param size - The width or height of one hexagon.
124
127
  * @returns The outer bounds of all hexagons.
128
+ * @throws RangeError If the size is not positive and finite.
125
129
  */
126
130
  getGridBounds(coordinates: Coordinate[], size: number): Bounds;
127
131
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"hex-grid.d.ts","sourceRoot":"","sources":["../src/hex-grid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAIjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAIvD,OAAO,KAAK,EACV,MAAM,EACN,KAAK,EACN,MAAM,eAAe,CAAA;AAUtB,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,uBAAuB,CAAA;AAU9B,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AAM,cAAc,GAAG,OAAO,GAAG;IACrC,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;GAEG;AACH,qBAAa,OAAO;;IAQlB;;;;OAIG;IACH,YAAY,WAAW,EAAE,eAAe,EAkBvC;IAED;;;;;OAKG;IACH,mBAAmB,CACjB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAuBT;IAED;;;;;;;;;;OAUG;IACH,UAAU,CACR,OAAO,EAAE,cAAc,GACtB,cAAc,EAAE,CA2BlB;IAED;;;;;;OAMG;IACH,aAAa,CACX,UAAU,EAAE,UAAU,GACrB,UAAU,EAAE,CAId;IAED;;;;;OAKG;IACH,iBAAiB,CACf,UAAU,EAAE,UAAU,GACrB,OAAO,CAMT;IAED;;;;;;;;;;;;;;OAcG;IACH,iBAAiB,CACf,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,GACX,KAAK,CAOP;IAED;;;;;;;;OAQG;IACH,gBAAgB,CACd,MAAM,EAAE,KAAK,EACb,IAAI,EAAE,MAAM,GACX,KAAK,EAAE,CAOT;IAED;;;;;;;;;;;;OAYG;IACH,aAAa,CACX,WAAW,EAAE,UAAU,EAAE,EACzB,IAAI,EAAE,MAAM,GACX,MAAM,CAOR;IAED;;;;;;;OAOG;IACH,kBAAkB,CAChB,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE,sBAA2B,GACnC,UAAU,EAAE,CAYd;IAED;;;;;;;;;;OAUG;IACH,yBAAyB,CACvB,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE,sBAA2B,GACnC,iBAAiB,EAAE,CAWrB;CACF"}
package/dist/hex-grid.js CHANGED
@@ -11,14 +11,29 @@ import { HexGridHexagonCreator } from './h-g-hexagon.js';
11
11
  * Represents a Midgard hex grid with a specific orientation.
12
12
  */
13
13
  export class HexGrid {
14
- orientation;
14
+ #orientation;
15
+ #neighbourCalculator;
16
+ #coordinatePositioner;
17
+ #hexagonGeometry;
18
+ #hexagonCreator;
19
+ #boundsCalculator;
15
20
  /**
16
21
  * Creates a new Midgard hex grid.
17
22
  *
18
23
  * @param orientation - The orientation of the hex grid.
19
24
  */
20
25
  constructor(orientation) {
21
- this.orientation = orientation;
26
+ this.#orientation = orientation;
27
+ this.#neighbourCalculator =
28
+ new NeighbourCalculator(orientation);
29
+ this.#coordinatePositioner =
30
+ new CoordinatePositioner(orientation);
31
+ this.#hexagonGeometry =
32
+ new HexagonGeometry(orientation);
33
+ this.#hexagonCreator =
34
+ new HexGridHexagonCreator(this.#coordinatePositioner, this.#hexagonGeometry);
35
+ this.#boundsCalculator =
36
+ new HexGridBoundsCalculator(this.#coordinatePositioner, this.#hexagonGeometry);
22
37
  }
23
38
  /**
24
39
  * Creates one single hexagon without any surrounding fill.
@@ -37,8 +52,7 @@ export class HexGrid {
37
52
  if (coordinate === undefined) {
38
53
  throw new Error('Could not create the single hexagon coordinate.');
39
54
  }
40
- const hexagonCreator = new HexGridHexagonCreator(this.orientation);
41
- return hexagonCreator.createHexagon(coordinate, options.hexDiameter);
55
+ return this.#hexagonCreator.createHexagon(coordinate, options.hexDiameter);
42
56
  }
43
57
  /**
44
58
  * Creates a complete Midgard grid around a skeleton.
@@ -49,17 +63,18 @@ export class HexGrid {
49
63
  *
50
64
  * @param options - The hexagon size and skeleton dimensions.
51
65
  * @returns All layered hexagons belonging to the complete grid.
66
+ * @throws RangeError If the hexagon diameter is invalid.
52
67
  */
53
68
  createGrid(options) {
69
+ HexGridHexagonCreator.validateHexDiameter(options.hexDiameter);
54
70
  const coordinates = this.getLayeredCoordinateRange({
55
71
  width: options.skeletonWidth,
56
72
  height: options.skeletonHeight
57
73
  }, {
58
74
  fillAround: true
59
75
  });
60
- const hexagonCreator = new HexGridHexagonCreator(this.orientation);
61
76
  return coordinates.map((coordinate) => {
62
- const hexagon = hexagonCreator.createHexagon(coordinate, options.hexDiameter);
77
+ const hexagon = this.#hexagonCreator.createHexagon(coordinate, options.hexDiameter);
63
78
  return {
64
79
  ...hexagon,
65
80
  zIndex: coordinate.zIndex
@@ -74,8 +89,7 @@ export class HexGrid {
74
89
  * @returns The six neighbouring coordinates.
75
90
  */
76
91
  getNeighbours(coordinate) {
77
- const neighbourCalculator = new NeighbourCalculator(this.orientation);
78
- return neighbourCalculator.getNeighbours(coordinate);
92
+ return this.#neighbourCalculator.getNeighbours(coordinate);
79
93
  }
80
94
  /**
81
95
  * Checks whether a coordinate is valid in the Midgard hex grid system.
@@ -100,10 +114,11 @@ export class HexGrid {
100
114
  * @param coordinate - The Midgard coordinate to position.
101
115
  * @param size - The width or height of one hexagon.
102
116
  * @returns The calculated center point.
117
+ * @throws RangeError If the size is not positive and finite.
103
118
  */
104
119
  getCenterPosition(coordinate, size) {
105
- const positioner = new CoordinatePositioner(this.orientation);
106
- return positioner.getCenterPosition(coordinate, size);
120
+ HexGridHexagonCreator.validateHexDiameter(size);
121
+ return this.#coordinatePositioner.getCenterPosition(coordinate, size);
107
122
  }
108
123
  /**
109
124
  * Calculates the six corner points of a hexagon
@@ -112,10 +127,11 @@ export class HexGrid {
112
127
  * @param center - The center point of the hexagon.
113
128
  * @param size - The dimension used to calculate the hexagon.
114
129
  * @returns The six corner points of the hexagon.
130
+ * @throws RangeError If the size is not positive and finite.
115
131
  */
116
132
  getHexagonPoints(center, size) {
117
- const geometry = new HexagonGeometry(this.orientation);
118
- return geometry.getHexagonPoints(center, size);
133
+ HexGridHexagonCreator.validateHexDiameter(size);
134
+ return this.#hexagonGeometry.getHexagonPoints(center, size);
119
135
  }
120
136
  /**
121
137
  * Calculates the outer geometric bounds of hexagons
@@ -128,10 +144,11 @@ export class HexGrid {
128
144
  * @param coordinates - The coordinates whose bounds should be calculated.
129
145
  * @param size - The width or height of one hexagon.
130
146
  * @returns The outer bounds of all hexagons.
147
+ * @throws RangeError If the size is not positive and finite.
131
148
  */
132
149
  getGridBounds(coordinates, size) {
133
- const boundsCalculator = new HexGridBoundsCalculator(this.orientation);
134
- return boundsCalculator.getGridBounds(coordinates, size);
150
+ HexGridHexagonCreator.validateHexDiameter(size);
151
+ return this.#boundsCalculator.getGridBounds(coordinates, size);
135
152
  }
136
153
  /**
137
154
  * Creates all coordinates belonging to a coordinate range
@@ -144,7 +161,7 @@ export class HexGrid {
144
161
  getCoordinateRange(range, options = {}) {
145
162
  const coordinateRange = new CoordinateRange({
146
163
  ...range,
147
- orientation: this.orientation
164
+ orientation: this.#orientation
148
165
  });
149
166
  const coordinateRangeFiller = new CoordinateRangeFiller(coordinateRange);
150
167
  return coordinateRangeFiller.getCoordinateRange(options);
@@ -1 +1 @@
1
- {"version":3,"file":"hex-grid.js","sourceRoot":"","sources":["../src/hex-grid.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAIrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAOrD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,EACL,eAAe,EAChB,MAAM,uBAAuB,CAAA;AAO9B,OAAO,EACL,qBAAqB,EACtB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EACL,eAAe,EAChB,MAAM,uBAAuB,CAAA;AAM9B,OAAO,EACL,uBAAuB,EACxB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,qBAAqB,EACtB,MAAM,kBAAkB,CAAA;AAkDzB;;GAEG;AACH,MAAM,OAAO,OAAO;IACD,WAAW,CAAiB;IAE7C;;;;OAIG;IACH,YAAY,WAA4B;QACtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACH,mBAAmB,CACjB,OAA6B;QAE7B,MAAM,WAAW,GAAG,IAAI,CAAC,kBAAkB,CACzC;YACE,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;SACV,EACD;YACE,UAAU,EAAE,KAAK;SAClB,CACF,CAAA;QAED,MAAM,UAAU,GAA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@@ -7,35 +7,13 @@ import type { GridOrientation } from './orientation.js';
7
7
  * between neighbouring coordinates is horizontal or vertical.
8
8
  */
9
9
  export declare class NeighbourCalculator {
10
- private readonly orientation;
10
+ #private;
11
11
  /**
12
12
  * Creates a new neighbour calculator.
13
13
  *
14
14
  * @param orientation - The orientation of the hex grid.
15
15
  */
16
16
  constructor(orientation: GridOrientation);
17
- /**
18
- * Returns the six neighbouring coordinates
19
- * in an x-dominated hex grid.
20
- *
21
- * Horizontal neighbours are two x-units away.
22
- * Diagonal neighbours are one x-unit and one y-unit away.
23
- *
24
- * @param coordinate - The coordinate whose neighbours should be found.
25
- * @returns The six neighbouring coordinates.
26
- */
27
- getXDominatedNeighbours(coordinate: Coordinate): Coordinate[];
28
- /**
29
- * Returns the six neighbouring coordinates
30
- * in a y-dominated hex grid.
31
- *
32
- * Vertical neighbours are two y-units away.
33
- * Diagonal neighbours are one x-unit and one y-unit away.
34
- *
35
- * @param coordinate - The coordinate whose neighbours should be found.
36
- * @returns The six neighbouring coordinates.
37
- */
38
- getYDominatedNeighbours(coordinate: Coordinate): Coordinate[];
39
17
  /**
40
18
  * Returns the six neighbouring coordinates
41
19
  * for this grid's orientation.
@@ -1 +1 @@
1
- {"version":3,"file":"neighbours.d.ts","sourceRoot":"","sources":["../src/neighbours.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvD;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiB;IAE7C;;;;OAIG;IACH,YAAY,WAAW,EAAE,eAAe,EAEvC;IAED;;;;;;;;;OASG;IACH,uBAAuB,CACrB,UAAU,EAAE,UAAU,GACrB,UAAU,EAAE,CAuCd;IAED;;;;;;;;;OASG;IACH,uBAAuB,CACrB,UAAU,EAAE,UAAU,GACrB,UAAU,EAAE,CAuCd;IAED;;;;;;OAMG;IACH,aAAa,CACX,UAAU,EAAE,UAAU,GACrB,UAAU,EAAE,CAMd;CACF"}
1
+ {"version":3,"file":"neighbours.d.ts","sourceRoot":"","sources":["../src/neighbours.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvD;;;;;GAKG;AACH,qBAAa,mBAAmB;;IAG9B;;;;OAIG;IACH,YAAY,WAAW,EAAE,eAAe,EAEvC;IA4GD;;;;;;OAMG;IACH,aAAa,CACX,UAAU,EAAE,UAAU,GACrB,UAAU,EAAE,CAMd;CACF"}
@@ -5,14 +5,14 @@
5
5
  * between neighbouring coordinates is horizontal or vertical.
6
6
  */
7
7
  export class NeighbourCalculator {
8
- orientation;
8
+ #orientation;
9
9
  /**
10
10
  * Creates a new neighbour calculator.
11
11
  *
12
12
  * @param orientation - The orientation of the hex grid.
13
13
  */
14
14
  constructor(orientation) {
15
- this.orientation = orientation;
15
+ this.#orientation = orientation;
16
16
  }
17
17
  /**
18
18
  * Returns the six neighbouring coordinates
@@ -24,7 +24,7 @@ export class NeighbourCalculator {
24
24
  * @param coordinate - The coordinate whose neighbours should be found.
25
25
  * @returns The six neighbouring coordinates.
26
26
  */
27
- getXDominatedNeighbours(coordinate) {
27
+ #getXDominatedNeighbours(coordinate) {
28
28
  const left = {
29
29
  x: coordinate.x - 2,
30
30
  y: coordinate.y
@@ -68,7 +68,7 @@ export class NeighbourCalculator {
68
68
  * @param coordinate - The coordinate whose neighbours should be found.
69
69
  * @returns The six neighbouring coordinates.
70
70
  */
71
- getYDominatedNeighbours(coordinate) {
71
+ #getYDominatedNeighbours(coordinate) {
72
72
  const upper = {
73
73
  x: coordinate.x,
74
74
  y: coordinate.y - 2
@@ -110,10 +110,10 @@ export class NeighbourCalculator {
110
110
  * @returns The six neighbouring coordinates.
111
111
  */
112
112
  getNeighbours(coordinate) {
113
- if (this.orientation === 'x-dominated') {
114
- return this.getXDominatedNeighbours(coordinate);
113
+ if (this.#orientation === 'x-dominated') {
114
+ return this.#getXDominatedNeighbours(coordinate);
115
115
  }
116
- return this.getYDominatedNeighbours(coordinate);
116
+ return this.#getYDominatedNeighbours(coordinate);
117
117
  }
118
118
  }
119
119
  //# sourceMappingURL=neighbours.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"neighbours.js","sourceRoot":"","sources":["../src/neighbours.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IACb,WAAW,CAAiB;IAE7C;;;;OAIG;IACH,YAAY,WAA4B;QACtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAED;;;;;;;;;OASG;IACH,uBAAuB,CACrB,UAAsB;QAEtB,MAAM,IAAI,GAAe;YACvB,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;YACnB,CAAC,EAAE,UAAU,CAAC,CAAC;SAChB,CAAA;QAED,MAAM,KAAK,GAAe;YACxB,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;YACnB,CAAC,EAAE,UAAU,CAAC,CAAC;SAChB,CAAA;QAED,MAAM,SAAS,GAAe;YAC5B,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;YACnB,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;SACpB,CAAA;QAED,MAAM,UAAU,GAAe;YAC7B,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;YACnB,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;SACpB,CAAA;QAED,MAAM,SAAS,GAAe;YAC5B,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;YACnB,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;SACpB,CAAA;QAED,MAAM,UAAU,GAAe;YAC7B,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;YACn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AAwB,CACtB,UAAsB;QAEtB,MAAM,KAAK,GAAe;YACxB,CAAC,EAAE,UAAU,CAAC,CAAC;YACf,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;SACpB,CAAA;QAED,MAAM,KAAK,GAAe;YACxB,CAAC,EAAE,UAAU,CAAC,CAAC;YACf,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;SACpB,CAAA;QAED,MAAM,SAAS,GAAe;YAC5B,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;YACnB,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;SACpB,CAAA;QAED,MAAM,UAAU,GAAe;YAC7B,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;YACnB,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;SACpB,CAAA;QAED,MAAM,SAAS,GAAe;YAC5B,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;YACnB,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;SACpB,CAAA;QAED,MAAM,UAAU,GAAe;YAC7B,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;YACnB,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;SACpB,CAAA;QAED,OAAO;YACL,KAAK;YACL,KAAK;YACL,SAAS;YACT,UAAU;YACV,SAAS;YACT,UAAU;SACX,CAAA;IACH,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CACX,UAAsB;QAEtB,IAAI,IAAI,CAAC,YAAY,KAAK,aAAa,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAClD,CAAC;QAED,OAAO,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;IAClD,CAAC;CACF"}
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midgard-hex-grid",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A reusable TypeScript module for working with hexagonal grids.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",