Draw an arc, pie, or chord
int PgDrawArc( PhPoint_t const *center,
PhPoint_t const *radii,
unsigned int start,
unsigned int end,
int flags );
This function builds a command in the draw buffer to draw an arc. The center argument defines the arc's center, and radii defines the arc's x and y radii.
The start and end arguments define the start and end angles (both arguments are specified in bi-grads; see below). The arc is drawn counter-clockwise, from the start angle to the end angle. To draw a complete circle, make the two angles equal to each other. An angle of 0 bi-grads is on the horizon to the right of the center.
![]() |
A circle is divided into 65536 gradations called binary gradations or bi-grads. Thus, 0x2000 is 45 degrees, 0x4000 is 90 degrees, 0x8000 is 180 degrees, and 0xC000 is 270 degrees. |
The flags argument controls what type of arc is drawn:
| To draw: | Set flags to: |
|---|---|
| A curve with the end points connected by a straight line. | Pg_ARC_CHORD |
| A curve with the end points connected to the arc's center. | Pg_ARC_PIE |
| The curve alone. | Pg_ARC |
You can OR one of the following into any flags value:
The following example:
DrawFillArc() {
PhPoint_t c = { 80, 60 };
PhPoint_t r = { 72, 52 };
PgSetFillColor( Pg_RED );
PgDrawArc( &c, &r, 0x0000, 0x4000, Pg_DRAW_FILL |
Pg_ARC_CHORD);
PgSetFillColor( Pg_YELLOW );
PgDrawArc( &c, &r, 0x5555, 0x9555, Pg_DRAW_FILL |
Pg_ARC_PIE);
PgSetStrokeColor( Pg_WHITE );
PgSetFillColor( Pg_PURPLE );
PgDrawArc( &c, &r, 0xAAAA, 0xEAAA,
Pg_DRAW_FILL_STROKE | Pg_ARC_PIE);
}
will draw:
The following example:
DrawStrokeArc() {
PhPoint_t c = { 80, 60 };
PhPoint_t r = { 72, 52 };
PgSetStrokeColor( Pg_WHITE );
PgDrawArc( &c, &r, 0x0000, 0x4000, Pg_DRAW_STROKE |
Pg_ARC_CHORD );
PgSetStrokeColor( Pg_YELLOW );
PgDrawArc( &c, &r, 0x5555, 0x9555, Pg_DRAW_STROKE |
Pg_ARC_PIE );
PgSetStrokeColor( Pg_YELLOW );
PgDrawArc( &c, &r, 0xAAAA, 0xEAAA, Pg_DRAW_STROKE |
Pg_ARC );
}
will draw:
Photon
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | No |
| Thread | No |
To draw stroked arcs, see also:
PgSetStrokeCap(), PgSetStrokeColor(), PgSetStrokeDash(), PgSetStrokeDither(), PgSetStrokeJoin(), PgSetStrokeWidth()
To draw filled arcs, see also:
PgSetFillColor(), PgSetFillDither(), PgSetFillTransPat()