Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

PgDrawGrid(), PgDrawGridCx()

Draw a grid

Synopsis:

int PgDrawGrid( PhRect_t const *r,
                PhPoint_t const *g );

int PgDrawGridCx( void *dc,
                  PhRect_t const *r,
                  PhPoint_t const *g );

Arguments:

dc
PgDrawGridCx() only. A void pointer to any type of draw context. Examples of draw contexts are:
r
A pointer to a PhRect_t structure that defines the upper left and lower right corners of the grid box.
g
A pointer to a PhPoint_t structure that defines the number of divisions in the grid. The number of lines drawn equals the number of divisions plus 1.

Library:

ph

Description:

These functions draw a rectangular grid. PgDrawGrid() works on the current draw context, while you can specify the draw context for PgDrawGridCx().

These functions build a draw command to draw the grid. The size of the grid is defined by the r argument with g.x+1 vertical lines and g.y+1 horizontal lines. If g.x is 0, no vertical lines are drawn; if g.y is 0, no horizontal lines are drawn.

Returns:

0
Success.
-1
The draw buffer is too small to hold the current draw state and the draw command.

Examples:

The following example uses PgDrawGrid() to make a grid of 8 squares by 8 squares; each square is 8 by 8 pixels:

void GridStandard() {
    PhRect_t r = { 8, 8, 72, 72 };
    PhPoint_t g = { 8, 8 };

    PgSetStrokeColor( Pg_WHITE );
    PgDrawGrid( &r, &g );
}

This code draws:

PgDrawGrid

The following example uses PgDrawGrid() to generate 20 ticks. Every 5th tick is made larger by calling PgDrawGrid() again with different parameters:

void GridTicks() {
  PhRect_t r = { 8, 24, 108, 28 };
  PhPoint_t g = { 20, 0 };

  PgSetStrokeColor( Pg_WHITE );
  PgDrawGrid( &r, &g );
  r.ul.y-=1;
  r.lr.y+=1;
  g.x=4;
  PgSetStrokeWidth( 3 );
  PgSetStrokeCap( Pg_POINT_CAP );
  PgDrawGrid( &r, &g );
  PgSetStrokeWidth( 0 );
}

This code draws:

PgDrawGrid

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PgSetStrokeCap*(), PgSetStrokeColor*(), PgSetStrokeDash*(), PgSetStrokeDither*(), PgSetStrokeJoin*(), PgSetStrokeTransPat*(), PgSetStrokeWidth*(), PgSetStrokeXORColor*(), PhPoint_t, PhRect_t

Drawing attributes and Lines, pixels, and pixel arrays in the Raw Drawing and Animation chapter of the Photon Programmer's Guide