Skip to content
This repository was archived by the owner on Dec 6, 2022. It is now read-only.

Grid API

Ian Glen edited this page Aug 15, 2013 · 2 revisions

scripts/graphics/grid.js

Grid object

The Grid class defines an isometric grid. When Dominion loads, it creates a new Grid object to manage the grid.

var grid = new Grid(canvas, origin);
var grid = new Grid(canvas, origin, movable, tileSize, color, strokeThickness);

Methods

Grid.center()

Moves the grid origin to the center of the canvas.

Grid.centerOnPoint(IsometricPoint point)

Moves the isometric point to the center of the canvas.

Grid.draw(OrthographicPoint startingPoint, OrthographicPoint endingPoint)

Draws an isometric grid on the canvas.

Optional: startingPoint and endingPoint: a grid will be drawn on the entire canvas if omitted.

Grid.getTileWidth()

Calculates the orthographic width of a tile when displayed isometrically.

Returns: (float) orthographic width

Grid.getTileHeight()

Calculates the orthographic height of a tile when displayed isometrically.

Returns: (float) orthographic height

Properties

Grid.canvas (Canvas)

Represents the Canvas object that is used.

Grid.origin (OrthographicPoint)

Represents the orthographic point where the isometric point is (0, 0).

Grid.movable (boolean)

Whether origin can me moved.

Grid.tileSize (float)

Represents the side length of a single square grid tile

Grid.color (Color)

Color of the grid lines when the grid is drawn.

Grid.strokeThickness (float)

Thickness of the lines when the grid is drawn.

Clone this wiki locally