Grid coordinates can be offset and/or inverted.
Consider a 100x100 pixel grid created by:
XgrCreateGrid ( @grid, 0, 200, 200, 100, 100, window, 0, 0 )
The upper-left : lower-right corners of this grid are located at window coordinates (200,200:299,299) , local coordinates (0,0:99,99) , and grid coordinates (0,0:99,99) .
When a grid is created, its grid coordinates and local coordinates are the same, (0,0:w-1,h-1) , where w = width and h = height in pixels.
But XgrSetGridBoxGrid ( grid, x1Grid, y1Grid, x2Grid, y2Grid ) can redefine the grid coordinates of the upper-left : lower-right corners of a grid to offset its grid coordinates horizontally and/or vertically from its local coordinates, as well as invert horizontally and/or vertically.
But grid coordinates are always measured in 1 pixel units, and XgrSetGridBoxGrid() cannot move grids or alter grid coordinates scale. So any time XgrSetGridBoxGrid() is called with x2Grid and/or y2Grid arguments that are not consistent with grid width and/or height, x2Grid and/or y2Grid are computed as follows:
IF (x1Grid <= x2Grid) THEN
x2Grid = x1Grid + (width - 1)
x2Grid = x1Grid - (width - 1)
IF (y1Grid <= y2Grid) THEN
y2Grid = y1Grid + (height - 1)
y2Grid = y1Grid - (height - 1)
Scaled coordinates can be offset and/or inverted and/or scaled.
A pair of floating-point scaled coordinates can be assigned to the upper-left : lower-right corners of every grid. For example, scaled coordinates (-320,+85:+14495,-40) could be assigned to the (upper-left:lower-right) corners of the grid by:
XgrSetGridBoxScaled ( grid, -320, 85, 14495, -40 )
The corners of this grid are now:
Coordinates Upper-Left Lower-Right
Local (0, 0) (99, 99)
Scaled (-320, +85) (+14495, -40)