Reference | Grid

These functions control the dimensions and background color of the grid.

PS.GridSize ( width, height )

Creates a grid with the specified dimensions. Any previous grid is removed.

Parameters:

  1. width : integer
  2. height : integer

Returns: Nothing

PS.GridSize() command is normally called in response to the PS.Init() engine event, which occurs upon game initialization.

The required width and height parameters indicate the desired number of columns and rows in the grid, respectively. Allowable values are 1 to 32. Values outside this range are clamped, and a warning is issued.

Passing the constant PS.DEFAULT in either parameter causes that dimension of the grid to assume its default value (8).

Example:

PS.Init = function ( options )
{
    // set up a 10 x 10 grid

    PS.GridSize( 10, 10 );

    // additional init code goes here
};

PS.GridBGColor ( color )

Sets and/or returns the background color of the grid.

Parameters:

  1. (optional) color, one of:
    • rgb : integer (a single multiplexed rgb value)
    • r, g, b: integer (separate r, g and b values)
    • [ r, g, b: integer ] (a single r, g, b array)
    • { r, g, b: integer } (a single r, g, b table)
    • PS.DEFAULT
    • PS.CURRENT

Returns: integer

Default: PS.COLOR_WHITE

The optional color parameter specifies the color to be assigned to the grid background. It can be supplied in any of four parameter formats:

(Refer to the documentation for PS.BeadColor() for examples of how to use the different color formats.)

The background immediately changes to the specified color.

If PS.DEFAULT is specified for color, the default color (PS.COLOR_WHITE) is applied to the background. If PS.CURRENT is specified, or no color parameter is supplied, the background is unchanged, and the return value is the current background color of the grid.

If a color parameter error is detected, the background color is not changed and the value PS.ERROR is returned.

The return value is the background color of the grid resulting from the function call.

NOTE: If you change the background color of the grid, check the color of the status line text to be sure it is still readable.

Example:

PS.Init = function ( options )
{
    // set up a 10 x 10 grid

    PS.GridSize( 10, 10 );

    // set background color to blue

    PS.GridBGColor( PS.COLOR_BLUE );

    // additional init code goes here
};