Skip to content

Commit

Permalink
Add Hexagon.center property
Browse files Browse the repository at this point in the history
  • Loading branch information
ericyd committed Jan 13, 2024
1 parent 4c6d4ff commit bec8b4c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/components/hexagon.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Hexagon extends Polygon {
/** @type {number} */
#apothem
/** @type {Vector2} */
#center
center

/**
* @param {HexagonAttributes} attributes
Expand All @@ -40,7 +40,7 @@ export class Hexagon extends Polygon {
}

super({ ...attributes, points })
this.#center = center
this.center = center
this.#circumradius = cr
this.#apothem = apothem ?? (cr * Math.sqrt(3)) / 2
}
Expand All @@ -52,7 +52,7 @@ export class Hexagon extends Polygon {
const hexagons = new Array(6)
for (let i = 0; i < 6; i++) {
const angle = (Math.PI / 3) * i + this.#rotation + Math.PI / 6
const center = this.#center.add(
const center = this.center.add(
vec2(Math.cos(angle), Math.sin(angle)).multiply(this.#apothem * 2),
)
hexagons[i] = new Hexagon({
Expand Down

0 comments on commit bec8b4c

Please sign in to comment.