home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
gd201.zip
/
gd-2.0.1
/
arc
< prev
next >
Wrap
Text File
|
2001-04-03
|
967b
|
32 lines
/* s and e are integers modulo 360 (degrees), with 0 degrees
being the rightmost extreme and degrees changing clockwise.
cx and cy are the center in pixels; w and h are the horizontal
and vertical diameter in pixels. Nice interface, but slow, since
I don't yet use Bresenham (I'm using an inefficient but
simple solution with too much work going on in it; generalizing
Bresenham to ellipses and partial arcs of ellipses is non-trivial,
at least for me) and there are other inefficiencies (small circles
do far too much work). */
void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)
{
int i;
int lx = 0, ly = 0;
int w2, h2;
w2 = w/2;
h2 = h/2;
while (e < s) {
e += 360;
}
for (i=s; (i <= e); i++) {
int x, y;
x = ((long)gdCosT[i % 360] * (long)w2 / 1024) + cx;
y = ((long)gdSinT[i % 360] * (long)h2 / 1024) + cy;
if (i != s) {
gdImageLine(im, lx, ly, x, y, color);
}
lx = x;
ly = y;
}
}