node package manager
Stop wasting time. Easily manage code sharing in your team. Create a free org ยป

node-image-terrain-array

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, rows)

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