Draw a stroked and/or filled bézier
int PgDrawBezier( PhPoint_t const *ptr, int num, PhPoint_t const *pos, int flags ); int PgDrawBezierv( PhPoint_t const *ptr, int num, PhPoint_t const *pos, int flags ); int PgDrawBezierCx( void *dc, PhPoint_t const *ptr, int num, PhPoint_t const *pos, int flags ); int PgDrawBezierCxv( void *dc, PhPoint_t const *ptr, int num, PhPoint_t const *pos, int flags );
ph
These functions build a command in the draw buffer to draw a multisegment Bézier curve from an array of points. PgDrawBezier() and PgDrawBezierv() work on the current draw context, while you can specify the draw context for PgDrawBezierCx() and PgDrawBezierCxv().
Each Bézier curve is defined by 4 points. The last point of a curve becomes the first point of the next curve. The first and fourth points are anchor points; the line passes through these. The second and third points are control points; the curve is “pulled” toward these points.
The flags argument must be one of the following:
You can OR flags with any combination of the following:
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.
If you call the “v” or “Cxv” form 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 point array. |
The following example:
DrawFillStrokeBezier() { PhPoint_t o = { 0, 0 }; PhPoint_t p[] = {43, 71, -92, -18, 344, -6, 20, 99}; PgSetStrokeDash( "\1", 1, 0x10000 ); PgSetStrokeColor( Pg_GRAY ); PgDrawPolygon( &p, 4, &o, Pg_DRAW_STROKE | Pg_CLOSED ); PgSetStrokeDash( NULL, 0, 0 ); PgSetStrokeColor( Pg_YELLOW ); PgSetFillColor( Pg_PURPLE ); PgDrawBezier( &p, 4, &o, Pg_DRAW_FILL_STROKE | Pg_CLOSED ); }
will draw:
The dotted lines show where the control points are relative to the anchor points.
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PgDrawPolygon*(), PgFlush(), PhPoint_t
To draw stroked Bézier curves, see also:
PgSetStrokeColor*(), PgSetStrokeCap*(), PgSetStrokeDash*(), PgSetStrokeDither*(), PgSetStrokeJoin*(), PgSetStrokeWidth*()
To draw filled Bézier curves, see also:
PgSetFillColor*(), PgSetFillDither*(), PgSetFillTransPat*()
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and Animation chapter of the Photon Programmer's Guide