Home Forums C Programming Draw Shapes and fill them

Viewing 1 reply thread
  • Author
    Posts
    • #1888
      will
      Participant

      Here is a small code that demonstrate how to make shapes in c language and fill them with colors and patterns.

      /*
      Author: Muhammad Saqib
      */
      #include
      #include
      #include
      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","LTB KSLASH_FILL",
      "HATCH_FILL", "XHATCH_FILL","INTERLEAVE_FILL","WIDE_DOR_FILL",
      "CLOSE_DOT_FILL","USER_FILL"
      };
      initgraph(&gd,&gm,"F:\tc\bgi");//Path to the BGI folder
      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;
      }

    • #3140
      indinfer
      Participant

      i m asking for any irregular polygon fill

Viewing 1 reply thread
  • The forum ‘C Programming’ is closed to new topics and replies.