Class: BaseHexagonalGrid

.base~BaseHexagonalGrid(options)

This is the base hexagonal grid, which supplies nodes in a hexagonal shape.

Constructor

new BaseHexagonalGrid(options)

Construct a basic hexagonal grid
Parameters:
Name Type Description
options Object Optional values to define the grid
Properties
Name Type Attributes Default Description
center HexNode <optional>
HexNode(0, 0) defines the center of the grid
radius integer <optional>
5 defines how many "rings" surround the center node
preInitialise function <optional>
overrides `BaseHexagonalGrid.preInitialise`
initialiseNode function overrides `BaseHexagonalGrid.initialiseNode`
postInitialise function <optional>
overrides `BaseHexagonalGrid.postInitialise`
preUpdate function <optional>
overrides `BaseHexagonalGrid.preUpdate`
updateNode function <optional>
overrides `BaseHexagonalGrid.updateNode`
postUpdate function <optional>
overrides `BaseHexagonalGrid.postUpdate`
preRender function <optional>
overrides `BaseHexagonalGrid.preRender`
renderNode function <optional>
overrides `BaseHexagonalGrid.renderNode`
postRender function <optional>
overrides `BaseHexagonalGrid.postRender`
Source:

Members

default_options

Defines what the default values are for the options of this class when instantiated, see `BaseHexagonalGrid.Constructor` for more details.
Source:

Methods

animate()

Used to update and render the grid once per frame, locked to run at most `BaseHexagonalGrid.fps` frames per second.
Source:

calculateGridWidth(hexagonalRadius, radiusopt)

Calculates the minimum width and height needed to fit `radius` nodes with a hexagonal radius of `hexagonalRadius`
Parameters:
Name Type Attributes Default Description
hexagonalRadius Number The distance from the center of all nodes to the edge
radius integer <optional>
BaseHexagonalGrid.radius The grid radius that should be visible
Source:

calculateNodeRadius(widthopt, heightopt, radiusopt)

Calculates the maximum hexagonal radius for each node such that all `radius` worth of nodes within `width` and `height`
Parameters:
Name Type Attributes Default Description
width integer <optional>
100 The width of the space to fill
height integer <optional>
100 The height of the space to fill
radius integer <optional>
BaseHexNode.radius The grid radius that should be visible
Source:

initialise()

Used to create and define nodes, called automatically one time when class is instantiated. Calls `BaseHexagonalGrid.preInitialise()`, then `BaseHexagonalGrid.initialiseNode(node, data) for each node` and finally `BaseHexagonalGrid.postInitialise()`.
Source:

initialiseNode()

An overridable function that is called once for each node in `BaseHexagonalGrid.nodes` during `BaseHexagonalGrid.initialise()`. Default behaviour is to do nothing.
Source:

postInitialise()

An overridable function that is called at the end of `BaseHexagonalGrid.initialise()`. Default behaviour is to do nothing.
Source:

postRender()

An overridable function that is called at the end of `BaseHexagonalGrid.render()`. Default behaviour is to do nothing.
Source:

postUpdate()

An overridable function that is called at the end of `BaseHexagonalGrid.update()`. Default behaviour is to do nothing.
Source:

preInitialise()

An overridable function that is called at the beginning of `BaseHexagonalGrid.initialise()`. Default behaviour is to populate `BaseHexagonalGrid.nodes` with with every node within `BaseHexagonalGrid.radius` of `BaseHexagonalGrid.center`, and to define `BaseHexagonalGrid.nodeData[node] = {}` for each node.
Source:

preRender()

An overridable function that is called at the start of `BaseHexagonalGrid.render()`. Default behaviour is to do nothing.
Source:

preUpdate()

An overridable function that is called at the start of `BaseHexagonalGrid.update()`. Default behaviour is to do nothing.
Source:

render()

Used to update nodes, called automatically at the start of each `BaseHexagonalGrid.animate` call. Calls `BaseHexagonalGrid.preRender()`, then `BaseHexagonalGrid.renderNode(node, data) for each node` and finally `BaseHexagonalGrid.postRender()`.
Source:

renderNode()

An overridable function that is called once for each node in `BaseHexagonalGrid.nodes` during `BaseHexagonalGrid.render()`. Default behaviour is to do nothing.
Source:

setRadius(radius)

Set the grid radius and regenerate nodes
Parameters:
Name Type Description
radius integer The desired radius
Source:

update()

Used to update nodes, called automatically at the start of each `BaseHexagonalGrid.animate` call. Calls `BaseHexagonalGrid.preUpdate()`, then `BaseHexagonalGrid.updateNode(node, data) for each node` and finally `BaseHexagonalGrid.postUpdate()`.
Source:

updateNode()

An overridable function that is called once for each node in `BaseHexagonalGrid.nodes` during `BaseHexagonalGrid.update()`. Default behaviour is to do nothing.
Source: