Constructor
new GridLayer()
Extends
Members
(static) layerOptions
_active :boolean
- Inherited From:
Track whether the canvas layer is currently active for interaction
Type:
- boolean
grid :BaseGrid
The Grid container
Type:
h
Get grid unit height
highlight :PIXI.Container
The Grid Highlight container
Type:
- PIXI.Container
highlightLayers :Object.<GridHighlight>
Map named highlight layers
Type:
- Object.<GridHighlight>
isHex :boolean
A boolean flag for whether the current grid is hexagonal
Type:
- boolean
name :string
- Inherited From:
The canonical name of the CanvasLayer
Type:
- string
options :CanvasLayerOptions
- Inherited From:
Options for this layer instance.
Type:
size :number
A convenient reference to the pixel grid size used throughout this layer
Type:
- number
type :number
The grid type rendered in this Scene
Type:
- number
w
Get grid unit width
Methods
activate() → {CanvasLayer}
- Inherited From:
Activate the CanvasLayer, deactivating other layers and marking this layer's children as interactive.
Returns:
The layer instance, now activated
- Type
- CanvasLayer
addHighlightLayer(name)
Define a new Highlight graphic
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name for the referenced highlight layer |
clearHighlightLayer(name)
Clear a specific Highlight graphic
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name for the referenced highlight layer |
deactivate() → {CanvasLayer}
- Inherited From:
Deactivate the CanvasLayer, removing interactivity from its children.
Returns:
The layer instance, now inactive
- Type
- CanvasLayer
destroyHighlightLayer(name)
Destroy a specific Highlight graphic
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name for the referenced highlight layer |
(async) draw(preview)
- Overrides:
Draw the grid
Parameters:
Name | Type | Description |
---|---|---|
preview |
Object | Override settings used in place of those saved to the Scene data |
getCenter() → {Array.<number>}
Given a pair of coordinates (x, y), return the center of the grid square which contains that point
Returns:
An Array [x, y] of the central point of the square which contains (x, y)
- Type
- Array.<number>
getHighlightLayer(name)
Obtain the highlight layer graphic by name
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name for the referenced highlight layer |
getSnappedPosition(x, y, intervalopt)
Given a pair of coordinates (x1,y1), return the grid coordinates (x2,y2) which represent the snapped position
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
number | The exact target location x |
||
y |
number | The exact target location y |
||
interval |
number |
<optional> |
1
|
An interval of grid spaces at which to snap, default is 1. If the interval is zero, no snapping occurs. |
getTopLeft() → {Array.<number>}
Given a pair of coordinates (x, y) - return the top-left of the grid square which contains that point
Returns:
An Array [x, y] of the top-left coordinate of the square which contains (x, y)
- Type
- Array.<number>
getZIndex() → {number}
- Inherited From:
Get the zIndex that should be used for ordering this layer vertically relative to others in the same Container.
Returns:
- Type
- number
highlightPosition(name, options)
Add highlighting for a specific grid position to a named highlight graphic
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name for the referenced highlight layer |
options |
object | Options for the grid position that should be highlighted |
isNeighbor(r0, c0, r1, c1)
Test if a specific row and column position is a neighboring location to another row and column coordinate
Parameters:
Name | Type | Description |
---|---|---|
r0 |
number | The original row position |
c0 |
number | The original column position |
r1 |
number | The candidate row position |
c1 |
number | The candidate column position |
measureDistance(origin, target, options) → {number}
Measure the distance between two point coordinates.
Example
let distance = canvas.grid.measureDistance({x: 1000, y: 1000}, {x: 2000, y: 2000});
Parameters:
Name | Type | Description |
---|---|---|
origin |
Object | The origin point |
target |
Object | The target point |
options |
MeasureDistancesOptions | Additional options which modify the measurement |
Returns:
The measured distance between these points
- Type
- number
measureDistances(segments, options)
Measure the distance traveled over an array of distance segments.
Parameters:
Name | Type | Description |
---|---|---|
segments |
Array.<object> | An array of measured segments |
options |
MeasureDistancesOptions | Additional options which modify the measurement |
(async) tearDown() → {Promise.<CanvasLayer>}
- Inherited From:
Deconstruct data used in the current layer in preparation to re-draw the canvas
Returns:
- Type
- Promise.<CanvasLayer>