hexgridr
Install with npm
npm install hexgridr --save
Use with node.js
var HexGrid = ; var hexGrid = orientation offsetType;var hexSet = hexGrid; //Example:var hexGrid = 'pointy-top''odd';var hexSet = hexGrid;
Check out the Demo page.
Parameters:
orientation {string}: 'pointy-top' or 'flat-top' The two supported types of hexes.
offsetType {string}: 'odd' or 'even' Rows (or columns) that contain the offset.
hexCount {int}: 0 to N Number of hexes.
layout {string}: 'hexagon' HexSet is build according to this layout. (more coming soon - rectangle).
originX {int}: X Coordinate of origin-hex. Each HexSet is build around the position of an origin-hex.
originY {int}: Y Coordinate of origin-hex. Each HexSet is build around the position of an origin-hex.
//You can also generate pixel-positions for a HexSet:var pixelSet = hexSet; //Example:var pixelSet = hexSet;
Parameters:
hexWidth {int} : 0 to N -- pixel-width of a Hex.
hexHeight {int}: 0 to N -- pixel-height of a Hex.
offsetX {int}: 0 to N -- X (or left) pixel-position of the origin-hex.
offsetY {int}: 0 to N -- Y (or top) pixel-position of the origin-hex.
Remarks:
The center of each hex is used as the pivot point for positioning (hexWidth/2, hexHeight/2).
Internally the library is using a coordinate system with three axes for most calculations (pair-wise perpendicular triple - x,y,z). But all relevant output also contains an x,y representation compatible with rectangular coordinate systems.