API - VadimGouskov/pretty-grid Wiki

Classes

Members

Functions

GridPoint

Kind: global class
Properties

Name Type Description
x: number the x coordinate of the point
y: number the x coordinate of the point

new GridPoint()

Represent a single point on the grid.

Grid

Kind: global class

new Grid()

The main Grid class containing all a two dimensional array of GridPoints and methods to manipulate the GridPoints on grid.

flat : Array.<GridPoint>

returns a one dimensional array of GridPoints of the grid. One column pushed after the other.

Kind: global variable

get() ⇒ Array.<Array.<GridPoint>>

Get all the current points on the grid warning: gets the points array by reference. Changes to individual points will be reflected in the original grid object. To get a deep copy use grid.copy(). eg. grid.copy.get()

Kind: global function

set() ⇒ void

Replaces all the current points on the grid warning: sets a reference to the provided points. Changes in made by this grid object to the points will be reflected in the provided points array.

Kind: global function

getPoint(col, row) ⇒ GridPoint

Gets a point from from indeces [col, row]

Kind: global function

Param Description
col the col index
row the row index

draw(func, condition) ⇒ void

Loops over the points in the grid, passing each point to the provided func parameter Provide a drawing function

Kind: global function

Param Type Description
func GridFunction a function that handles drawing of each individual point
condition ConditionFunction an optional condition for which points to draw

translate(x, y, [condition]) ⇒ Grid

Translates the entire grid by x en y coordinates

Kind: global function
Returns: Grid - returns @this Grid Object. Used for chaining Grid methods

Param Type Description
x number the x coordinates to translate the points with
y number the y coordinates to translate the points with
[condition] ConditionFunction an optional condition for which points to translate

copy() ⇒ Grid

Creates a deep copy of the current grid object

Kind: global function
Returns: Grid - a new instance of Grid of with the same gridpoint values as @this Grid