The Grid Layer

The Grid Layer is positioned 2nd from bottom in the layers of the Canvas. The Grid Layer is responsible for orienting and segmenting the game space into grid spaces. Currently only a square grid is supported but hex grid support is flagged as a feature for work during Beta development.

The Grid provides convenience tools for measuring distance, restricting token movement, and providing guide lines for anchoring wall segments or other canvas features.

Mod developers may wish to interact with or manipulate this layer and can do so using the singleton instance of the GridLayer() class which is accessible from within the client as canvas.grid.

class GridLayer()

A CanvasLayer responsible for drawing a square grid

GridLayer.addHighlightLayer(name)

Define a new Highlight graphic

Arguments:
  • name
GridLayer.clearHighlightLayer(name)

Clear a specific Highlight graphic

Arguments:
  • name
GridLayer.destroyHighlightLayer(name)

Destroy a specific Highlight graphic

Arguments:
  • name
GridLayer.draw()

Draw square grid lines

GridLayer.getCenter(x, y)

Given a pair of coordinates (x, y), return the center of the grid square which contains that point

Returns:Array – An Array [x, y] of the central point of the square which contains (x, y)
GridLayer.getSnappedPosition(x, y, interval)

Given a pair of coordinates (x1,y1), return the grid coordinates (x2,y2) which represent the snapped position

Arguments:
  • x (Number) – The exact target location x
  • y (Number) – The exact target location y
  • interval (Number) – An interval of grid spaces at which to snap, default is 1.
GridLayer.getTopLeft(x, y)

Given a pair of coordinates (x, y) - return the top-left of the grid square which contains that point

Returns:Array – An Array [x, y] of the top-left coordinate of the square which contains (x, y)
GridLayer.grid

type: PIXI.Container

The Grid container

GridLayer.h

Get grid unit height

GridLayer.highlight

type: PIXI.Container

The Grid Highlight container

GridLayer.highlightLayers

type: Object

Map named highlight layers

GridLayer.isNeighbor(r0, c0, r1, c1)

Test if a specific row and column position is a neighboring location to another row and column coordinate

GridLayer.measureDistance(p0, p1)

Measure the distance between two pixel coordinates

Arguments:
  • p0 (Object) – The origin coordinate {x, y}
  • p1 (Object) – The destination coordinate {x, y}
GridLayer.size

type: Number

A convenient reference to the pixel grid size used throughout this layer

GridLayer.type

type: String

The grid type rendered in this Scene

GridLayer.w

Get grid unit width