Small C Language Program to show the drawing and filling of some basic shapes like rectangle, circle etc… with colors and different shades. First of all I have created a characters array of patterns that will fill the drawing, then initialize the graphics mode and the draw the shapes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | //Please change BGI directory according to your Turbo C Directory #include <stdio.h> #include <conio.h> #include <graphics.h> main () { int gd =DETECT, gm, maxx,maxy , x=40,y=40,fst; char str[40]; char *pattern[]={ "EMPTY_FILL", "SOLID_FILL","LTSLASH_FILL","SLASH_FILL","BKSLASH_FILL","LTBKSLASH_FILL", "HATCH_FILL", "XHATCH_FILL","INTERLEAVE_FILL","WIDE_DOR_FILL", "CLOSE_DOT_FILL","USER_FILL" }; initgraph(&gd,&gm,"e:\\tc\\bgi"); maxx=getmaxx(); maxy=getmaxy(); rectangle(0,10,maxx,maxy); setcolor(WHITE); outtextxy(175,0,"Pre-Defined Fill styles"); for (fst=0;fst<12;fst++) { setfillstyle(fst, MAGENTA); bar (x,y,x+80,y+80); itoa (fst,str,10); outtextxy(x,y+100,str); outtextxy(x,y+100,pattern[fst]); x=x+150; if (x>490) { y=y+150; x=40; } } getch(); closegraph(); restorecrtmode(); return 0; } |