grid / Exports / Grid

Class: Grid

Grid class Represents a grid has many helper functions to manipulate the grid

Constructors

constructor

new Grid(rows, cols, id?)

Grid constructor

Parameters

NameTypeDescription
rowsnumberNumber of rows
colsnumberNumber of columns
id?stringid of the grid

Defined in

Grid.ts:76open in new window

Properties

cells

cells: Cell[][]

Cells of the grid

Defined in

Grid.ts:54open in new window


cols

cols: number

number of columns within the grid

Defined in

Grid.ts:42open in new window


comment

comment: string

Comment of the grid

Defined in

Grid.ts:46open in new window


created

created: number

Date of creation(db)

Defined in

Grid.ts:62open in new window


id

id: string

Id of the grid(db)

Defined in

Grid.ts:58open in new window


optionsId

optionsId: string

Id of the options(db)

See

GridOptions Might be removed soon with books

Defined in

Grid.ts:68open in new window


rows

rows: number

nuber of rows within the grid

Defined in

Grid.ts:38open in new window


title

title: string

Title of the grid

Defined in

Grid.ts:50open in new window

Methods

decrement

decrement(v, direction): Cell

Decrement a position by a direction, and return the cell at the new position

Parameters

NameTypeDescription
vVecstarting position
directionDirectiondirection to decrement

Returns

Cell

the cell at the new position, or nullCell if the new position is out of bounds

Defined in

Grid.ts:236open in new window


getBounds

getBounds(coordinates, direction): Bounds

Given a cell and a direction, returns the bounds of the word

Parameters

NameTypeDescription
coordinatesVeccoordinates of the cell
directionDirectionThe direction of the word

Returns

Bounds

All the cells of the word, and the start and end positions

Defined in

Grid.ts:319open in new window


getCell

getCell(coordinates): Cell

Get the cell at the given coordinates

Parameters

NameTypeDescription
coordinatesVeccoordinates of the cell

Returns

Cell

the cell at the given coordinates

Defined in

Grid.ts:247open in new window


highlight

highlight(cells): void

Highlight the given cells (unhighlight all other cells)

Parameters

NameTypeDescription
cellsCell[]cells to highlight

Returns

void

Defined in

Grid.ts:254open in new window


increment

increment(v, direction): Cell

Increment a position by a direction, and return the cell at the new position

Parameters

NameTypeDescription
vVecstarting position
directionDirectiondirection to increment

Returns

Cell

the cell at the new position, or nullCell if the new position is out of bounds

Defined in

Grid.ts:224open in new window


isDefinition

isDefinition(point): boolean

Checks if the cell at the given coordinates is a definition cell

Parameters

NameTypeDescription
pointVeccoordinates

Returns

boolean

true if the cell is a definition cell

Defined in

Grid.ts:105open in new window


isValid

isValid(point): boolean

Checks wether coordinates are within the bounds of the grid

Parameters

NameTypeDescription
pointVeccoordinates

Returns

boolean

false if x or y is out of bounds

Defined in

Grid.ts:97open in new window


resize

resize(rows, cols): void

Resizes the grid to the given dimensions

Parameters

NameTypeDescription
rowsnumberheight of the grid
colsnumberwidth of the grid

Returns

void

Defined in

Grid.ts:114open in new window


serialize

serialize(): string

Converts the grid to a sreialized string

Returns

string

GridState JSON string

Defined in

Grid.ts:356open in new window


setArrow

setArrow(v, index, direction): void

Set the arrow of a definition cell

See

Grid.setArrow

Parameters

NameTypeDescription
vVec-
indexnumberThe index of the arrow to set
directionArrowDirarrow direction

Returns

void

Defined in

Grid.ts:197open in new window


setDefinition

setDefinition(coordinates, value): void

Set the cell at the given coordinates as a definition cell (or not)

Parameters

NameTypeDescription
coordinatesVec
valuebooleantrue to make it a definition cell, false to make it a normal cell

Returns

void

Defined in

Grid.ts:134open in new window


setSpaceH

setSpaceH(coordinates, value): void

Set horizontal space of a cell

Parameters

NameTypeDescription
coordinatesVeccoordinates of the cell
valuebooleantrue to set the space, false to remove it

Returns

void

Defined in

Grid.ts:206open in new window


setSpaceV

setSpaceV(coordinates, value): void

Set vertical space of a cell

Parameters

NameTypeDescription
coordinatesVeccoordinates of the cell
valuebooleantrue to set the space, false to remove it

Returns

void

Defined in

Grid.ts:214open in new window


setText

setText(coordinates, value): void

Set the text to the cell at the given coordinates

Parameters

NameTypeDescription
coordinatesVec
valuestringtext to set

Returns

void

Defined in

Grid.ts:150open in new window


setWord

setWord(word, point, direction): void

Write a word within the grid, one letter per cell

Parameters

NameTypeDescription
wordstringword to write
pointVecstart coordinates of the word
directionDirectionwriting direction

Returns

void

Defined in

Grid.ts:164open in new window


suggest

suggest(words, start, directions): void

Set the suggestion of the given cells

Parameters

NameTypeDescription
wordsstring[]Words to suggest
startVec[]start position of each word
directionsDirection[]direction of each word

Returns

void

Defined in

Grid.ts:270open in new window


equal

Static equal(a, b): boolean

Checks if two cells have the same coordinates

Parameters

NameTypeDescription
aVecFirst cell
bVecSecond cell

Returns

boolean

Weather the two cells have the same coordinates

Defined in

Grid.ts:291open in new window


getDirVec

Static getDirVec(direction): Vector

Converts a direction to a vector

Parameters

NameTypeDescription
directionDirectionDirection to convert

Returns

Vector

Vector corresponding to the direction

Defined in

Grid.ts:300open in new window


newCell

Static newCell(x, y): Cell

Creates a new cell

Parameters

NameTypeDescription
xnumberx coordinate
ynumbery coordinate

Returns

Cell

new cell

Defined in

Grid.ts:396open in new window


perpendicular

Static perpendicular(direction): Direction

Converts a direction to its perpendicular vector

Parameters

NameTypeDescription
directionDirectionDirection to convert

Returns

Direction

Vector perpendicular to the direction

Defined in

Grid.ts:310open in new window


setArrow

Static setArrow(cell, index, direction): void

Set one of the arrows of a definition cell

Parameters

NameTypeDescription
cellCellcell to set the arrow
indexnumberThe index of the arrow to set
directionArrowDirarrow direction

Returns

void

Defined in

Grid.ts:180open in new window


unserialize

Static unserialize(s): Grid

Creates a grid from a serialized string

Parameters

NameTypeDescription
sstringGridState JSON string

Returns

Grid

A new grid

Defined in

Grid.ts:374open in new window