Draw a trend graph
int PgDrawTrend( short const *ptr, PhPoint_t const *pos, int num, int delta, int buflen, int bufoff, unsigned flags ); int PgDrawTrendv( short const *ptr, PhPoint_t const *pos, int num, int delta, int buflen, int bufoff, unsigned flags ); int PgDrawTrendCx( void *dc, short const *ptr, PhPoint_t const *pos, int num, int delta, int buflen, int bufoff, unsigned flags ); int PgDrawTrendCxv( void *dc, short const *ptr, PhPoint_t const *pos, int num, int delta, int buflen, int bufoff, unsigned flags );
ph
These functions build a command in the draw buffer to draw a trend graph.
The ptr argument points to an array of short values. Each of these values is used as either the x or the y coordinate; the other coordinate is calculated by adding delta to the previous value.
For example, if flags is Pg_TREND_VERT, the coordinates would be calculated as follows:
pos.x + *(ptr+0), pos.y + (delta * 0) pos.x + *(ptr+1), pos.y + (delta * 1) pos.x + *(ptr+2), pos.y + (delta * 2) ... pos.x + *(ptr+num-1), pos.y + (delta * (num-1))
The pos argument defines the origin of the trend graph and the num argument controls the number of values to be drawn.
The flags argument controls how the trend will be drawn. It must be one of the following:
The buflen and bufoff arguments aren't currently used, and must be set to 0 for future compatibility.
If you call the “v” forms of this function, the data isn't
physically copied into the draw buffer. Instead, a pointer
to the array is stored until the draw buffer is flushed.
Make sure you call PgFlush()
before you modify the array.
If the data is in shared memory, the mx form of this function will automatically pass a shared memory reference instead of the array. |
PgDrawTrend() and PgDrawTrendv() work on the current draw context, while you can specify the draw context dc for PgDrawTrendCx() and PgDrawTrendCxv().
The following example:
void HTrend() { short data[512]; PhPoint_t p = { 0, 80 }; int i; for (i=0; i<512; i++) data[i] = (i & 127) - 64; PgSetStrokeColor( Pg_WHITE ); PgDrawTrend( &data, &p, 256, 2, 0, 0, Pg_TREND_HORIZ ); }
will draw:
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PgDrawPolygon*(), PgSetStrokeColor*(), PgSetStrokeWidth*(), PgFlush*(), PhPoint_t
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and Animation chapter of the Photon Programmer's Guide