Outputs an array of terrain types from an input of image, cols and rows. To be used to generate svg hexmap.
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitignore
README.md
index.js
package.json

README.md

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

Overview

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 :)

Example

Turn this -

An image of part of the world

Into this -

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

Usage

getTerrain(imageFile, cols)

Further Development

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

Tasks

  • 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 :)