/* Structures and Bitmaps Program */ #include #include #include #include #include #include /* typedef struct { int x, y; } POINT; POINT polygon [6] = { {50, 0}, {90, 75}, {0, 25}, {100, 25}, {10, 75}, {50, 0} }; */ int main () { clrscr (); int gdriver = DETECT, gmode, errorcode; initgraph (&gdriver, &gmode, "g:\\bgi"); errorcode = graphresult (); if (errorcode != grOk) { printf ("Graphics error: %s\n", grapherrormsg (errorcode)); printf ("Press Anykey to halt: "); getch (); exit (1); } /* "graphics main prorgam lines" go here */ //struct POINT // { // int x, y; // }; //struct POINT polygon[6] = // { // {50, 0}, {90, 75}, {0, 25}, // {100, 25}, {10, 75}, {50, 0} // }; typedef struct { int x, y; } POINT; POINT polygon [6]; polygon[0].x = 50; polygon[0].y = 0; polygon[1].x = 90; polygon[1].y = 75; polygon[2].x = 0; polygon[2].y = 25; polygon[3].x = 100; polygon[3].y = 25; polygon[4].x = 10; polygon[4].y = 75; polygon[5].x = 50; polygon[5].y = 0; //POINT polygon [6] = // { //{50, 0}, {90, 75}, {0, 25}, //{100, 25}, {10, 75}, {50, 0} // }; setcolor (CYAN); drawpoly (6, (int far*) polygon); int xmax, ymax, color, i; xmax = getmaxx (); ymax = getmaxy (); void *image; image = malloc (imagesize (0,0,100,75)); if (image) { getimage (0, 0, 100, 75, image); while (!kbhit ()) { color = random (15)+1; setcolor (color); setfillstyle (random(10), color); for (i=0; i<5; i++) { polygon[i].x = random(xmax); polygon[i].y = random(ymax); } polygon[i] = polygon[0]; fillpoly (6, (int far*) polygon); } //putimage (random(xmax), random(ymax), image, COPY_PUT); } getch (); closegraph (); return 0; }