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:
- width : integer
- 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:
- (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:
- A single multiplexed RGB value in the range 0x000000 to 0xFFFFFF.
- Three separate r, g and b values in the range 0-255 (0x00-0xFF).
- A single array containing at least three elements in which array[0]=r, array[1]=g and array[2]=b, each specified as an integer in the range 0-255 (0x00-0xFF). Any array elements beyond the first three are ignored.
- A single table containing three elements named r, g and b, each assigned to an integer in the range 0-255 (0x00-0xFF). Any other elements in the table are ignored.
(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
};