0

I need to generate and plot a grid of hexagons from an arbitrarily sized list of values. The grid should start from some center 0,0 and grow outwards clockwise, each ring starting from top/top-center of the previous one. To explain better, an animation of expected outputs for list sizes 1 to 19.

enter image description here

The closest I came to a solution was from the response to this question, but in that example the input is fixed to 7 pre-generated coordinates - I need to generate them dynamically.

Natsukane
  • 681
  • 1
  • 8
  • 19
  • Is this grid the final target and therefore it's completely unimportant how this picture is generated? Or do you want to process/access it partly or as a whole further and therefore have additional requirements? – SpghttCd Nov 08 '18 at 06:01
  • @SpghttCd It's unimportant how it's generated as long as the order is preserved - ie. the first value in the output coordinate list should be the center hex and correspond to the first value in the input list. Really, the question isn't how to generate the image itself (I can mostly figure that out from the question I linked), but how to generate a properly ordered list of (x,y) coordinates from some input list of size N and per-hex radius R. – Natsukane Nov 08 '18 at 22:09
  • To generate a spiral you can generate N rings. For each ring, make N steps in a direction, then turn right, and do this for all 6 directions until the ring is complete. https://www.redblobgames.com/grids/hexagons/#rings-spiral – amitp Jan 10 '19 at 00:42

0 Answers0