Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pg/pgdrawpolygon.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pg/pgdrawpolygon.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pg/pgdrawpolygon.html on line 9

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pg/pgdrawpolygon.html on line 9

PgDrawPolygon(), PgDrawPolygonv(), PgDrawPolygonCx(), PgDrawPolygonCxv()

Draw a stroked and/or filled polygon

Synopsis:

int  PgDrawPolygon( PhPoint_t const *ptr,
                    int num,
                    PhPoint_t const *pos,
                    int flags );

int  PgDrawPolygonv( PhPoint_t const *ptr,
                      int num,
                      PhPoint_t const *pos,
                      int flags );

int  PgDrawPolygonCx( void *dc,
                      PhPoint_t const *ptr,
                      int num,
                      PhPoint_t const *pos,
                      int flags );

int  PgDrawPolygonCxv( void *dc,
                       PhPoint_t const *ptr,
                       int num,
                       PhPoint_t const *pos,
                       int flags );

Library:

ph

Description:

These functions build a command in the draw buffer to draw a polygon from an array of points, pointed to by ptr, with num entries.


Note: The array of points must fit in the draw buffer for all these functions.

PgDrawPolygon() and PgDrawPolygonv() work on the current draw context, while you can specify the draw context dc for PgDrawPolygonCx() and PgDrawPolygonCxv().

The flags argument must be one of the following:

Pg_DRAW_STROKE
Draw a stroked polygon.
Pg_DRAW_FILL
Draw a filled polygon.
Pg_DRAW_FILL_STROKE
Draw a filled polygon, then stroke it.

You can OR flags with any combination of the following:

Pg_CLOSED
Connect the last point to the first.
Pg_RELATIVE
Use relative coordinates to draw the polygon. Each point is relative to the previous point.

For absolute coordinates, pos is added to each point pointed to by ptr. For relative coordinates, the first coordinate is the sum of pos and the first point of the array; any subsequent coordinate is the sum of the previous point and the next point of the array.


Note: 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() or PgFlushCx() before you modify the point array.

Returns:

0
Successful completion
-1
The draw buffer is too small to hold the current draw state, the draw command, and the data. Increase the size of the draw buffer or decrease the number of points.

Examples:

The following example:

DrawFillStrokePoly() {
    PhPoint_t   o = { 0, 0 };
    PhPoint_t   p[] = { 80, 8, 120, 120, 16, 32,
                        136, 32, 40, 120 };

    PgSetStrokeColor( Pg_WHITE );
    PgSetFillColor( Pg_PURPLE );
    PgDrawPolygon( &p, 5, &o, Pg_DRAW_FILL_STROKE |
                                      Pg_CLOSED );
}

will draw:

PgDrawPolygon,fillstroke

The following example:

DrawRelPoly() {
    PhPoint_t   o = { 0, 0 };
    PhPoint_t   p[] = { 80, 8, 40, 112, -104, -88,
                        120, 0, -96, 88 };

    PgSetStrokeColor( Pg_WHITE );
    PgSetFillColor( Pg_PURPLE );
    PgDrawPolygon( &p, 5, &o, Pg_DRAW_FILL_STROKE |
                                        Pg_CLOSED |
                                        Pg_RELATIVE );
}

will draw:

PgDrawPolygon,relative

The following example:

DrawUnclosedPoly() {
    PhPoint_t   o = { 0, 0 };
    PhPoint_t   p[] = { 80, 8, 120, 120, 16, 32,
                        136, 32, 40, 120 };

    PgSetStrokeColor( Pg_WHITE );
    PgSetFillColor( Pg_PURPLE );
    PgDrawPolygon( &p, 5, &o, Pg_DRAW_FILL_STROKE );
}

will draw:

PgDrawPolygon,unclosed

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PgFlush(), PhPoint_t

To draw stroked polygons, see also:

PgSetStrokeColor*(), PgSetStrokeCap*(), PgSetStrokeDash*(), PgSetStrokeDither*(), PgSetStrokeJoin*(), PgSetStrokeWidth*()

To draw filled polygons, see also:

PgSetFillColor*(), PgSetFillDither*(), PgSetFillTransPat*()

Arcs, ellipses, polygons, and rectangles in the Raw Drawing and Animation chapter of the Photon Programmer's Guide


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pg/pgdrawpolygon.html on line 296

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pg/pgdrawpolygon.html on line 296