node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org ยป


Node Image to Terrain Array by Box It Off

Input - png buffer, number of columns

Output - array of average hsv values for each hexagon, array of centre points of hexagons, hexagon radius, number of rows


This is a module for a bigger project. It is self contained and will output to a file in the output folder. On its own it is not very useful but watch this space :)


Turn this -

An image of part of the world

Into this -

[{ h: 91, s: 55, v: 21 }, {....}, .....], [[ 9.804061174918171, 16.9811320754717 ], [ ....... ], ......], 11.320754716981131


getTerrain(imageFile, cols, rows)

Further Development

  • output code for rendering map
  • command line inputs
  • Browser gui


  • get image width and height
  • get hex radius
  • get center point of each hex
  • get pixel sample (array->rgba values) function
  • get average colour(array->rgb) of each sample
  • get hsv(array) values from rgb averages
  • return array of hsv values, array of hex centre points, hex radius
  • clean up code :)