RAJAN's profileRAJAN's spacePhotosBlogListsMore Tools Help

Blog


    April 08

    c++ programme on greeting card,using graphics..

    #include<graphics.h>
    #include<conio.h>
    #include<iostream.h>
    #include<stdlib.h>
    #include<stdio.h>
    #include<dos.h>
    /*my first graphics programme,completed at 3:45am,8th april,2007....
    latter modified n included more animations at 12:15pm,8th april,2007.
      email-> rajan_vaish@hotmail.com
      weblink->http://rajanvaish.spaces.live.com/
            "HARI OM"
    */
    class flower
    {
    protected:
    int xco,yco;
    int linecolour;
    int fillcolour;
    int linestyle;
    int linewidth;
    int pattern;
    int rad;
    public:
     flower()
     {
     rad=10;
     xco=0;
     yco=0;
     linecolour=WHITE;
     fillcolour=WHITE;
     linestyle=0;//solid_line
     linewidth=0;//normal width
     pattern=1;//solid fill
     };
     void set(int x,int y,int r,int lc,int fc,int ls,int lw,int pat)
      {
      rad=r;
      xco=x;
      yco=y;
      linecolour=lc;
      fillcolour=fc;
      linestyle=ls;
      linewidth=lw;
      pattern=pat;
      }
      void draw()
      {
      setcolor(linecolour);
      setlinestyle(linestyle,0,linewidth);
      circle(xco,yco,rad);
      setfillstyle(pattern,fillcolour);
      floodfill(xco,yco,linecolour);
      }
     };
    class human
    {
    protected:
    int xco;
    int yco;
    int x1[5];
    int y1[5];
    int x2[5];
    int y2[5];
    int rad;
    int linecolourf;
    int fillcolour;    //o is for other body parts of human like body,legs,hands
    int linestylef;
    int linewidthf;    //f is for face
    int pattern;
    int linecolouro[5];
    int linestyleo[5];
    int linewidtho[5];
    public:
     human()
     {
     xco=0;
     yco=0;
    // x1=0;
    // y1=0;
    // x2=0;
    // y2=0;
     rad=10;
     linecolourf=0;
     fillcolour=0;
     linestylef=0;
     linewidthf=0;
     pattern=0;
    // linecolouro=0;
    //linewidtho=0;
    // linestyleo=0;
     }
    void setface(int x,int y,int r,int lc,int fc,int ls,int lw,int pat)
     {
     xco=x;
     yco=y;
     rad=r;
     linecolourf=lc;
     fillcolour=fc;
     linestylef=ls;
     linewidthf=lw;
     pattern=pat;
     }
     void setbody(int xx1,int yy1,int xx2,int yy2,int lco,int lso,int lwo)
      {
       x1[0]=xx1;
       y1[0]=yy1;
       x2[0]=xx2;
       y2[0]=yy2;
       linecolouro[0]=lco;
       linestyleo[0]=lso;
       linewidtho[0]=lwo;
       }
      void setlhand(int xx1,int yy1,int xx2,int yy2,int lco,int lso,int lwo)
      {
       x1[1]=xx1;
       y1[1]=yy1;
       x2[1]=xx2;
       y2[1]=yy2;
       linecolouro[1]=lco;
       linestyleo[1]=lso;
       linewidtho[1]=lwo;
       }
      void setrhand(int xx1,int yy1,int xx2,int yy2,int lco,int lso,int lwo)
      {
       x1[2]=xx1;
       y1[2]=yy1;
       x2[2]=xx2;
       y2[2]=yy2;
       linecolouro[2]=lco;
       linestyleo[2]=lso;
       linewidtho[2]=lwo;
       }
       void setlleg(int xx1,int yy1,int xx2,int yy2,int lco,int lso,int lwo)
      {
       x1[3]=xx1;
       y1[3]=yy1;
       x2[3]=xx2;
       y2[3]=yy2;
       linecolouro[3]=lco;
       linestyleo[3]=lso;
       linewidtho[3]=lwo;
       }
       void setrleg(int xx1,int yy1,int xx2,int yy2,int lco,int lso,int lwo)
      {
       x1[4]=xx1;
       y1[4]=yy1;
       x2[4]=xx2;
       y2[4]=yy2;
       linecolouro[4]=lco;
       linestyleo[4]=lso;
       linewidtho[4]=lwo;
       }
     void drawface()
     {
     setcolor(linecolourf);
     setlinestyle(linestylef,0,linewidthf);
     circle(xco,yco,rad);
     setfillstyle(pattern,fillcolour);
     floodfill(xco,yco,linecolourf);
     }
     void drawbody()
     {
     setcolor(linecolouro[0]);
     setlinestyle(linestyleo[0],0,linewidtho[0]);
     line(x1[0],y1[0],x2[0],y2[0]);
     }
     void drawlhand()
     {
     setcolor(linecolouro[1]);
     setlinestyle(linestyleo[1],0,linewidtho[1]);
     line(x1[1],y1[1],x2[1],y2[1]);
     }

     void drawrhand()
     {
     setcolor(linecolouro[2]);
     setlinestyle(linestyleo[2],0,linewidtho[2]);
     line(x1[2],y1[2],x2[2],y2[2]);
     }
     void drawlleg()
     {
     setcolor(linecolouro[3]);
     setlinestyle(linestyleo[3],0,linewidtho[3]);
     line(x1[3],y1[3],x2[3],y2[3]);
     }

     void drawrleg()
     {
     setcolor(linecolouro[4]);
     setlinestyle(linestyleo[4],0,linewidtho[4]);
     line(x1[4],y1[4],x2[4],y2[4]);
     }
    };
    class humanx : public human
     {
     public:
     void setface(int a,int b,int c,int d,int e,int f,int g,int h)
      {
      human::setface(a,b,c,d,e,f,g,h);
      }
      void setbody(int a,int b,int c,int d,int e,int f,int g)
      {
      human::setbody(a,b,c,d,e,f,g);
      }
       void setlhand(int a,int b,int c,int d,int e,int f,int g)
      {
      human::setlhand(a,b,c,d,e,f,g);
      }
        void setrhand(int a,int b,int c,int d,int e,int f,int g)
      {
      human::setrhand(a,b,c,d,e,f,g);
      }
        void setlleg(int a,int b,int c,int d,int e,int f,int g)
      {
      human::setlleg(a,b,c,d,e,f,g);
      }
        void setrleg(int a,int b,int c,int d,int e,int f,int g)
      {
      human::setrleg(a,b,c,d,e,f,g);
      }
      void draw()
      {
      human::drawface();
      human::drawbody();
      human::drawlhand();
      human::drawrhand();
      human::drawlleg();
      human::drawrleg();
      }
     };
     

    void main()
    {
    int driver,mode;
    driver=DETECT;
    initgraph(&driver,&mode,"c:\\tc\\bgi");
    int midx;
    int midy;
    int errorcode;
    int c,o,l,u,r,z;

     /* read result of initialization */
      errorcode = graphresult();
       if (errorcode != grOk)  /* an error occurred */
       {
          printf("Graphics error: %s\n", grapherrormsg(errorcode));
          printf("Press any key to halt:");
          getch();
          exit(1); /* terminate with an error code */
       }
       midx = getmaxx() / 2;
       midy = getmaxy() / 2;
       setcolor(getmaxcolor());
     //  for(int x=1;x<=15;x++)
      // { delay(100);
      // setcolor(4);
      // rectangle(130,10,550,450);
      // rectangle(125,5,555,455);
      // }
       /* draw the circle */
      flower flow1[11],flow2[11];

     humanx hu[6];
     hu[2].setface(334,350,5,14,14,0,0,1);//boy2.1-face
     hu[2].setbody(334,355,334,380,2,0,3);//body
     hu[2].setlhand(334,355,320,370,4,0,3);//lft hand -down
     hu[2].setrhand(334,355,348,370,4,0,3);//rgt hand
     hu[2].setlleg(334,380,330,400,4,0,3);//lft leg  -contracted
     hu[2].setrleg(334,380,338,400,4,0,3);//rgt leg

     hu[3].setface(334,350,5,14,14,0,0,1);//boy2.2-face
     hu[3].setbody(334,355,334,380,2,0,3);//body
     hu[3].setlhand(334,355,313,340,1,0,3);//lft hand -up
     hu[3].setrhand(334,355,353,340,1,0,3);//rgt hand
     hu[3].setlleg(334,380,320,400,1,0,3);//lft leg  -expanded
     hu[3].setrleg(334,380,348,400,1,0,3);//rgt leg
     hu[0].setface(200,350,5,14,14,0,0,1);//boy1.1-face
     hu[0].setbody(200,355,200,380,2,0,3);//body
     hu[0].setlhand(200,355,180,360,5,0,3);//lft hand    -lft
     hu[0].setrhand(200,355,185,370,5,0,3);//rgt hand
     hu[0].setlleg(200,380,186,400,5,0,3);//lft leg     -expanded
     hu[0].setrleg(200,380,214,400,5,0,3);//rgt leg
     hu[1].setface(200,350,5,14,14,0,0,1);//boy1.2-face
     hu[1].setbody(200,355,200,380,2,0,3);//body
     hu[1].setrhand(200,355,220,360,11,0,3);//rgt hand   -rgt
     hu[1].setlhand(200,355,215,370,11,0,3);//lft hand
     hu[1].setlleg(200,380,196,400,11,0,3);//lfg leg    -contracted
     hu[1].setrleg(200,380,204,400,11,0,3);//rgt leg
     hu[4].setface(460,350,5,14,14,0,0,1);//boy3.1-face
     hu[4].setbody(460,355,460,380,2,0,3);//body
     hu[4].setrhand(460,355,480,360,5,0,3);//rgt hand -rgt
     hu[4].setlhand(460,355,475,370,5,0,3);//lft hand
     hu[4].setlleg(460,380,446,400,5,0,3);//lft leg  -expanded
     hu[4].setrleg(460,380,474,400,5,0,3);//rgt leg
     hu[5].setface(460,350,5,14,14,0,0,1);//boy3.2-face
     hu[5].setbody(460,355,460,380,2,0,3);//body
     hu[5].setlhand(460,355,440,360,11,0,3);//lft hand -lft
     hu[5].setrhand(460,355,445,370,11,0,3);//rgt hand
     hu[5].setlleg(460,380,456,400,11,0,3);//lft leg -contracted
     hu[5].setrleg(460,380,464,400,11,0,3);//rgt leg
     
       setcolor(5);
       rectangle(130,10,550,450);//smaller
       setfillstyle(1,8);
       floodfill(300,269,5);
     
     moveto(185,20);
     settextstyle(GOTHIC_FONT,HORIZ_DIR,4);
     settextjustify(LEFT_TEXT,TOP_TEXT);
     setcolor(4);
     outtext("HAPPY");
     moveto(335,20);
     settextstyle(GOTHIC_FONT,HORIZ_DIR,4);
     settextjustify(LEFT_TEXT,TOP_TEXT);
     setcolor(4);
     outtext("BIRTHDAY");
     moveto(150,150);
     settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1);
     settextjustify(LEFT_TEXT,TOP_TEXT);
     setcolor(3);
     outtext("~* gud luck for all ur future ventures *~");
     moveto(450,420);
     settextstyle(SMALL_FONT,HORIZ_DIR,5);
     settextjustify(LEFT_TEXT,TOP_TEXT);
     setcolor(14);
     outtext("-rajan");
     
     
     for(int j=0;j<10;j++)
     {
     sound(200);
     delay(100);
     nosound();
     setcolor(j+1);
     rectangle(125,5,555,455); //bigger
    // delay(100);
     setcolor(j);
     rectangle(120,0,560,460); //even bigger
     moveto(270,100);
     settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
     settextjustify(LEFT_TEXT,TOP_TEXT);
     setcolor(j+2);
     outtext("xRAJANx");
     if(j%2==0)
      {
     hu[0].setlhand(200,355,180,360,5,0,3);//lft hand    -lft
     hu[0].setrhand(200,355,185,370,5,0,3);//rgt hand
     hu[0].setlleg(200,380,186,400,5,0,3);//lft leg     -expanded
     hu[0].setrleg(200,380,214,400,5,0,3);//rgt leg
     hu[0].draw();
     hu[2].setlhand(334,355,320,370,4,0,3);//lft hand -down
     hu[2].setrhand(334,355,348,370,4,0,3);//rgt hand
     hu[2].setlleg(334,380,330,400,4,0,3);//lft leg  -contracted
     hu[2].setrleg(334,380,338,400,4,0,3);//rgt leg
     hu[2].draw();
     hu[4].setrhand(460,355,480,360,5,0,3);//rgt hand -rgt
     hu[4].setlhand(460,355,475,370,5,0,3);//lft hand
     hu[4].setlleg(460,380,446,400,5,0,3);//lft leg  -expanded
     hu[4].setrleg(460,380,474,400,5,0,3);//rgt leg
     hu[4].draw();
     hu[1].setrhand(200,355,220,360,8,0,3);//rgt hand   -rgt
     hu[1].setlhand(200,355,215,370,8,0,3);//lft hand
     hu[1].setlleg(200,380,196,400,8,0,3);//lfg leg    -contracted
     hu[1].setrleg(200,380,204,400,8,0,3);//rgt leg
     hu[1].draw();
     hu[3].setlhand(334,355,313,340,8,0,3);//lft hand -up
     hu[3].setrhand(334,355,353,340,8,0,3);//rgt hand
     hu[3].setlleg(334,380,320,400,8,0,3);//lft leg  -expanded
     hu[3].setrleg(334,380,348,400,8,0,3);//rgt leg
     hu[3].draw();
     hu[5].setlhand(460,355,440,360,8,0,3);//lft hand -lft
     hu[5].setrhand(460,355,445,370,8,0,3);//rgt hand
     hu[5].setlleg(460,380,456,400,8,0,3);//lft leg -contracted
     hu[5].setrleg(460,380,464,400,8,0,3);//rgt leg
     hu[5].draw();
       flow1[0].set(midx-100, midy+30,25,6,6,0,3,11);//bigL
       flow1[1].set(254,269,10,12,14,0,0,1);//0
       flow1[2].set(249,249,10,14,12,0,0,1);//1 its anticlockwise
       flow1[3].set(232,234,10,12,14,0,0,1);//2
       flow1[4].set(211,233,10,14,12,0,0,1);//3
       flow1[5].set(190,245,10,12,14,0,0,1);//4
       flow1[6].set(183,267,10,14,12,0,0,1);//5
       flow1[7].set(190,288,10,12,14,0,0,1);//6
       flow1[8].set(208,302,10,14,12,0,0,1);//7
       flow1[9].set(230,305,10,12,14,0,0,1);//8
       flow1[10].set(247,290,10,14,12,0,0,1);//9
       flow2[0].set(450,269,25,6,6,0,3,11);//bigR
       flow2[1].set(485,269,10,12,14,0,0,1);//0
       flow2[2].set(480,249,10,14,12,0,0,1);//1
       flow2[3].set(463,234,10,12,14,0,0,1);//2
       flow2[4].set(442,233,10,14,12,0,0,1);//3
       flow2[5].set(421,245,10,12,14,0,0,1);//4
       flow2[6].set(414,267,10,14,12,0,0,1);//5
       flow2[7].set(421,288,10,12,14,0,0,1);//6
       flow2[8].set(439,302,10,14,12,0,0,1);//7
       flow2[9].set(461,305,10,12,14,0,0,1);//8
       flow2[10].set(478,290,10,14,12,0,0,1);//9
       delay(100);
       for(int co=0;co<=10;co++)
        {
        delay(100);
       flow1[co].draw();
       flow2[co].draw();
       delay(100);
        }
     delay(100);
     }
     else
     {
     hu[0].setlhand(200,355,180,360,8,0,3);//lft hand    -lft
     hu[0].setrhand(200,355,185,370,8,0,3);//rgt hand
     hu[0].setlleg(200,380,186,400,8,0,3);//lft leg     -expanded
     hu[0].setrleg(200,380,214,400,8,0,3);//rgt leg
     hu[0].draw();
     hu[2].setlhand(334,355,320,370,8,0,3);//lft hand -down
     hu[2].setrhand(334,355,348,370,8,0,3);//rgt hand
     hu[2].setlleg(334,380,330,400,8,0,3);//lft leg  -contracted
     hu[2].setrleg(334,380,338,400,8,0,3);//rgt leg
     hu[2].draw();
     hu[4].setrhand(460,355,480,360,8,0,3);//rgt hand -rgt
     hu[4].setlhand(460,355,475,370,8,0,3);//lft hand
     hu[4].setlleg(460,380,446,400,8,0,3);//lft leg  -expanded
     hu[4].setrleg(460,380,474,400,8,0,3);//rgt leg
     hu[4].draw();
     hu[1].setrhand(200,355,220,360,11,0,3);//rgt hand   -rgt
     hu[1].setlhand(200,355,215,370,11,0,3);//lft hand
     hu[1].setlleg(200,380,196,400,11,0,3);//lfg leg    -contracted
     hu[1].setrleg(200,380,204,400,11,0,3);//rgt leg
     hu[1].draw();
     hu[3].setlhand(334,355,313,340,1,0,3);//lft hand -up
     hu[3].setrhand(334,355,353,340,1,0,3);//rgt hand
     hu[3].setlleg(334,380,320,400,1,0,3);//lft leg  -expanded
     hu[3].setrleg(334,380,348,400,1,0,3);//rgt leg
     hu[3].draw();
     hu[5].setlhand(460,355,440,360,11,0,3);//lft hand -lft
     hu[5].setrhand(460,355,445,370,11,0,3);//rgt hand
     hu[5].setlleg(460,380,456,400,11,0,3);//lft leg -contracted
     hu[5].setrleg(460,380,464,400,11,0,3);//rgt leg
     hu[5].draw();
       flow1[0].set(midx-100, midy+30,25,6,6,0,3,11);//bigL
       flow1[1].set(254,269,10,14,12,0,0,1);//0
       flow1[2].set(249,249,10,12,14,0,0,1);//1 its anticlockwise
       flow1[3].set(232,234,10,14,12,0,0,1);//2
       flow1[4].set(211,233,10,12,14,0,0,1);//3
       flow1[5].set(190,245,10,14,12,0,0,1);//4
       flow1[6].set(183,267,10,12,14,0,0,1);//5
       flow1[7].set(190,288,10,14,12,0,0,1);//6
       flow1[8].set(208,302,10,12,14,0,0,1);//7
       flow1[9].set(230,305,10,14,12,0,0,1);//8
       flow1[10].set(247,290,10,12,14,0,0,1);//9
       flow2[0].set(450,269,25,6,6,0,3,11);//bigR
       flow2[1].set(485,269,10,14,12,0,0,1);//0
       flow2[2].set(480,249,10,12,14,0,0,1);//1
       flow2[3].set(463,234,10,14,12,0,0,1);//2
       flow2[4].set(442,233,10,12,14,0,0,1);//3
       flow2[5].set(421,245,10,14,12,0,0,1);//4
       flow2[6].set(414,267,10,12,14,0,0,1);//5
       flow2[7].set(421,288,10,14,12,0,0,1);//6
       flow2[8].set(439,302,10,12,14,0,0,1);//7
       flow2[9].set(461,305,10,14,12,0,0,1);//8
       flow2[10].set(478,290,10,12,14,0,0,1);//9
       delay(100);
       for(int cox=0;cox<=10;cox++)
        {delay(100);
        flow1[cox].draw();
        flow2[cox].draw();
        delay(100);
        }
     delay(100);
     }
    }
    /*copyright.ALL RIGHTS RESERVED.
    no copying of this piece of work is allowed,unless u gain written permission
    by rajan vaish...any copyin of this project is punishable offence.n decided
    by law,government of india..
    lol..jus kiddin,tryin to make it bit professional..hehehhe....*/
     
     getch();
     closegraph();
    }