The square grid class.

Hierarchy (view full)

Constructors

Properties

diagonals: number

The rule for diagonal measurement (see CONST.GRID_DIAGONALS).

size: number

The size of a grid space in pixels.

sizeX: number

The width of a grid space in pixels.

sizeY: number

The height of a grid space in pixels.

distance: number

The distance of a grid space in units.

units: string

The distance units used in this grid.

style: string

The style of the grid.

thickness: number

The thickness of the grid.

color: Color

The color of the grid.

alpha: number

The opacity of the grid.

Accessors

  • get isGridless(): boolean
  • Is this a gridless grid?

    Returns boolean

  • get isSquare(): boolean
  • Is this a square grid?

    Returns boolean

  • get isHexagonal(): boolean
  • Is this a hexagonal grid?

    Returns boolean

Methods

  • Returns the offset of the grid space corresponding to the given coordinates.

    Parameters

    • coords: GridCoordinates

      The coordinates

    Returns GridOffset

    The offset

  • Parameters

    • __namedParameters: {
          x: any;
          y: any;
          width: any;
          height: any;
      }
      • x: any
      • y: any
      • width: any
      • height: any

    Returns number[]

  • Parameters

    • coords: any

    Returns {
        i: GridOffset;
        j: any;
    }[]

  • Parameters

    • coords1: any
    • coords2: any

    Returns boolean

  • Parameters

    • coords: any
    • direction: any

    Returns GridOffset

  • Parameters

    • point: any
    • direction: any

    Returns Point

  • Returns the top-left point of the grid space corresponding to the given coordinates. If given a point, the top-left point of the grid space that contains it is returned.

    Parameters

    • coords: GridCoordinates

      The coordinates

    Returns Point

    The top-left point

  • Returns the center point of the grid space corresponding to the given coordinates. If given a point, the center point of the grid space that contains it is returned.

    Parameters

    • coords: GridCoordinates

      The coordinates

    Returns Point

    The center point

  • Returns {
        x: number;
        y: number;
    }[]

  • Parameters

    • coords: any

    Returns {
        x: number;
        y: number;
    }[]

  • Parameters

    • point: any
    • __namedParameters: {
          mode: any;
          resolution: number;
      }
      • mode: any
      • resolution: number

    Returns {
        x: any;
        y: any;
    }

    • x: any
    • y: any
  • Parameters

    • waypoints: any
    • __namedParameters: {
          cost: any;
      }
      • cost: any
    • result: any

    Returns void

  • Parameters

    • point: any
    • direction: any
    • distance: any

    Returns {
        x: any;
        y: any;
    }

    • x: any
    • y: any
  • Parameters

    • center: any
    • radius: any

    Returns Point[]

  • Parameters

    • sceneWidth: any
    • sceneHeight: any
    • padding: any

    Returns {
        width: any;
        height: any;
        x: number;
        y: number;
        rows: number;
        columns: number;
    }

    • width: any
    • height: any
    • x: number
    • y: number
    • rows: number
    • columns: number
  • Measure a shortest, direct path through the given waypoints.

    Parameters

    • waypoints: any[]

      The waypoints the path must pass through

    • Optional options: {
          cost: GridMeasurePathCostFunction;
      } = {}

      Additional measurement options

      • cost: GridMeasurePathCostFunction

        The function that returns the cost for a given move between grid spaces (default is the distance travelled along the direct path)

    Returns GridMeasurePathResult

    The measurements a shortest, direct path through the given waypoints.

  • Get the cone polygon given the radius in grid units and the angle in degrees for this grid. The points of the polygon are returned ordered in positive orientation. In gridless grids an approximation of the true cone with a deviation of less than 0.25 pixels is returned.

    Parameters

    • origin: Point

      The origin point of the cone.

    • radius: number

      The radius in grid units.

    • direction: number

      The direction in degrees.

    • angle: number

      The angle in degrees.

    Returns Point[]

    The points of the cone polygon.

  • Snap the point to the nearest center of a square.

    Parameters

    • point: Point

      The point

    • resolution: number

      The grid resolution

    Returns Point

    The snapped point

  • Snap the point to the nearest vertex of a square.

    Parameters

    • point: Point

      The point

    • resolution: number

      The grid resolution

    Returns Point

    The snapped point

  • Snap the point to the nearest vertex or center of a square.

    Parameters

    • point: Point

      The point

    • resolution: number

      The grid resolution

    Returns Point

    The snapped point

  • Snap the point to the nearest edge of a square.

    Parameters

    • point: Point

      The point

    • resolution: number

      The grid resolution

    Returns Point

    The snapped point

  • Snap the point to the nearest edge or center of a square.

    Parameters

    • point: Point

      The point

    • resolution: number

      The grid resolution

    Returns Point

    The snapped point

  • Snap the point to the nearest edge or vertex of a square.

    Parameters

    • point: Point

      The point

    • resolution: number

      The grid resolution

    Returns Point

    The snapped point

  • Snap the point to the nearest edge, vertex, or center of a square.

    Parameters

    • point: Point

      The point

    • resolution: number

      The grid resolution

    Returns Point

    The snapped point

  • Snap the point to the nearest top/bottom side of a square.

    Parameters

    • point: Point

      The point

    • resolution: number

      The grid resolution

    Returns Point

    The snapped point

  • Snap the point to the nearest left/right side of a square.

    Parameters

    • point: Point

      The point

    • resolution: number

      The grid resolution

    Returns Point

    The snapped point

  • Calculate the cost of the direct path segment.

    Parameters

    • from: GridOffset

      The coordinates the segment starts from

    • to: GridOffset

      The coordinates the segment goes to

    • cost: GridMeasurePathCostFunction

      The cost function

    • diagonals: number

      The number of diagonal moves that have been performed already

    Returns number

    The cost of the path segment

  • Get the circle polygon given the radius in grid units (EQUIDISTANT).

    Parameters

    • center: Point

      The center point of the circle.

    • radius: number

      The radius in grid units (positive).

    Returns Point[]

    The points of the circle polygon.

  • Get the circle polygon given the radius in grid units (EXACT).

    Parameters

    • center: Point

      The center point of the circle.

    • radius: number

      The radius in grid units (positive).

    Returns Point[]

    The points of the circle polygon.

  • Get the circle polygon given the radius in grid units (APPROXIMATE).

    Parameters

    • center: Point

      The center point of the circle.

    • radius: number

      The radius in grid units (positive).

    Returns Point[]

    The points of the circle polygon.

  • Get the circle polygon given the radius in grid units (ALTERNATING_1/2).

    Parameters

    • center: Point

      The center point of the circle.

    • radius: number

      The radius in grid units (positive).

    • firstDouble: boolean

      2/1/2 instead of 1/2/1?

    Returns Point[]

    The points of the circle polygon.

  • Get the circle polygon given the radius in grid units (RECTILINEAR/ILLEGAL).

    Parameters

    • center: Point

      The center point of the circle.

    • radius: number

      The radius in grid units (positive).

    Returns Point[]

    The points of the circle polygon.