Header file:
graphics.h
Synopsis:
void getarccoords(struct arcoordstype *coordinates);
struct arccoordstype {
int x, y; /* center position of arc */
int xstart, ystart; /* starting position of arc */
int xend, yend; /* ending position of arc */
}
Description:
getarccoords() used to get the paramaters passed to last call to arc().
getarccoords function in c graphics
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
int main(void) {
/* request auto detection */
int graphicDriver = DETECT, graphicMode, err;
struct arccoordstype arc1, arc2;
int i, midx, midy, x1, y1, x2, y2;
/* initialize graphics and local variables */
initgraph(&graphicDriver, &graphicMode,
"C:/TURBOC3/BGI");
/* read result of initialization */
err = graphresult();
/* an error occurred */
if (err != grOk) {
printf("Graphic Error: %s\n",
grapherrormsg(err));
return 0;
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* draw arc and get coordinates */
for (i = 0; i < 15; i++) {
setcolor(i);
setfillstyle(i % 12, i);
arc(midx - 100, midy, 30, 330, 50);
getarccoords(&arc1);
x1 = arc1.xstart, y1 = arc1.ystart;
x2 = arc1.xend, y2 = arc1.yend;
arc(midx + 100, midy, 0 , 150, 50);
getarccoords(&arc2);
line(x1, y1, arc2.xend, arc2.yend);
arc(midx + 100, midy, 210, 360, 50);
getarccoords(&arc1);
line(x2, y2, arc1.xstart, arc1.ystart);
floodfill(midx, midy, i);
delay(400);
}
getch();
/* clean up */
closegraph();
return 0;
}
Output: (getarccoords built-in function in c graphics.h)
No comments:
Post a Comment