Skip to content

Outputs an array of terrain types from an input of image, cols and rows. To be used to generate svg hexmap.

Notifications You must be signed in to change notification settings

jjmax75/node-image-terrain-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Outputs an array of terrain types from an input of image, cols and rows. To be used to generate svg hexmap.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published