flauwekeul / honeycomb

Create hex grids easily, in node or the browser.
https://abbekeultjes.nl/honeycomb
MIT License
630 stars 57 forks source link

t.distance is not a function #54

Closed arucar closed 4 years ago

arucar commented 4 years ago

Hi everybody I dont' know if it's an error or if i do something wrong but whith this code i got the error: t.distance is not a function.

const Hex = Honeycomb.extendHex({ size: 30 }); const Grid = Honeycomb.defineGrid(Hex); const grid = Grid.rectangle({ width: 50, height: 50 }); const hexBetween = grid.hexesBetween({ x: 0, y: 0 }, { x: 5, y: 5 }); console.log(hexBetween);

Someone can say me if it's a problem or where i do a mistake ?

flauwekeul commented 4 years ago

hexesBetween() expects to be called with actual hexes (that have the distance() method), you're calling it with plain objects with x and y properties.

This should fix it:

grid.hexesBetween(Hex(0, 0), Hex(5, 5));
arucar commented 4 years ago

oh i miss that point on the doc.. ok ^^ thank you a lot :)