|
楼主 |
发表于 2004-5-8 17:41:27
|
显示全部楼层
<>函数名: getarccoords
功 能: 取得最后一次调用arc的坐标
用 法: void far getarccoords(struct arccoordstype far *arccoords);
程序例: <>#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h> <>int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
struct arccoordstype arcinfo;
int midx, midy;
int stangle = 45, endangle = 270;
char sstr[80], estr[80]; <P>/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); <P>/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
/* terminate with an error code */
exit(1);
} <P> midx = getmaxx() / 2;
midy = getmaxy() / 2; <P>/* draw arc and get coordinates */
setcolor(getmaxcolor());
arc(midx, midy, stangle, endangle, 100);
getarccoords(&arcinfo); <P>/* convert arc information into strings */
sprintf(sstr, "*- (%d, %d)",
arcinfo.xstart, arcinfo.ystart);
sprintf(estr, "*- (%d, %d)",
arcinfo.xend, arcinfo.yend); <P> /* output the arc information */
outtextxy(arcinfo.xstart,
arcinfo.ystart, sstr);
outtextxy(arcinfo.xend,
arcinfo.yend, estr); <P> /* clean up */
getch();
closegraph();
return 0;
}
</P> |
|