Showing posts with label basics of graphics. Show all posts
Showing posts with label basics of graphics. Show all posts

program to print a welcome screen?

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<process.h>
void viewall();
void help();
void exit_screen();
void newentry();
void welcome();
void main()
{
int gd=DETECT,h;
initgraph(&gd,&h,"c:/tc");
welcome();
}
void welcome()
{
clrscr();
int choice1;
setbkcolor(7);
setcolor(4);
outtextxy(190,190,"   *****************   ");
setcolor(6);
outtextxy(190,220,"   ENTER YOUR CHOICE   ");
setcolor(4);
outtextxy(190,250,"   ******************  ");
setcolor(6);
outtextxy(190,270,"1.  Enter a new entry  ");
outtextxy(190,285,"2.  See all enteries   ");
outtextxy(190,300,"3.  Need help ");
outtextxy(190,315,"4.  Exit   ");
cin>>choice1;
switch(choice1)
{
case 1:
newentry();
break;
case 2:
viewall();
break;
case 3:
help();
break;
case 4:
exit_screen();
break;
default:
clrscr();
setbkcolor(7);
setcolor(6);
outtextxy(190,270,"INVLAID CHOICE....");
getch();
welcome();
break;
}
}

void exit_screen()
{
clrscr();
setcolor(6);
outtextxy(190,190,"*******************************************  ");


outtextxy(190,280,"*******************************************");
setcolor(4);
outtextxy(190,220,"This master piece is brought To you From::");
delay(5000);
outtextxy(190,250,"           VIKAS KUNAL AND ANIL");

delay(5000);
clrscr();
setbkcolor(7);
setcolor(6);
outtextxy(190,190," **********************************************  ");


outtextxy(190,280," **********************************************");
setcolor(4);
outtextxy(190,220,"     For more msterpiece programs");
delay(5000);
outtextxy(190,250,"  contact at:9888163098,9779423162,9988070508   ");
getch();
exit(1);
}
void newentry()
{
clrscr();
setbkcolor(7);
setcolor(6);
outtextxy(190,200,"    U hv opened the new entry screen");
delay(5000);
outtextxy(190,250,"  press any key to go to main screen   ");
getch();
welcome();
}
void viewall()
{
clrscr();
setbkcolor(7);
setcolor(6);
outtextxy(190,200,"     u hv entered the screen to view all");
delay(5000);
outtextxy(190,250,"  press any key to go to main screen   ");

getch();
welcome();
}
void help()
{
clrscr();
setbkcolor(7);
setcolor(6);
outtextxy(190,200,"     u hv entered th screen to help");
delay(5000);
outtextxy(190,250,"  press any key to go to main screen   ");
getch();
welcome();
}

program to print a line

#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
int a,b,c,k;
void main()
{   clrscr();
    int d,mm,e;
    d=DETECT;
    initgraph(&d,&mm,"c:/tc");
    e=graphresult();
    if(e!=0)
    {  cout<<" graphics r not opened";
       getch();
       return;
    }
    REGS n,m;
    n.x.ax=0;
    int86(0x33,&n,&m);
    k=m.x.ax;
    if(k==0)
    return;
    int aa,bb,t1,t2,p=0;
    while(!kbhit())
    {  n.x.ax=1;
       int86(0x33,&n,&m);
       n.x.ax=3;
       int86(0x33,&n,&m);
       a=m.x.cx;
       b=m.x.dx;
       c=m.x.bx;

       if(c==1)
       {   if(p==0)
       {  aa=a;
          bb=b;
          p++;
       }
       if(t1!=a||t2!=b)
       {  setcolor(0);
          line(aa,bb,t1,t2);
        //  cleardevice();
       }
       setcolor(5);
       line(aa,bb,a,b);
       t1=a;
       t2=b;
       }
       else
       p=0;
   }
    getch();
    closegraph();
 }

program to print a barcode

#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main()
{
int d,m,e;
d=DETECT;
initgraph(&d,&m,"c:/tc");
e=graphresult();
if(e!=0)
{  cout<<" graphics r not opened";
   getch();
   return;
}
setbkcolor(4);
for(int i=0;i<128;i++)
{ setcolor(i);
  line((i*3+50),50,(i*3+50),80);
}
getch();
}

program to print all the ascii values

#include<iostream.h>
#include<conio.h>
void show(char a,char b,int row,int col)
{  char far*p=(char far*)0xb8000000;
   p+=row*160+col*2;
   *p=a;
   p++;
   *p=b;
   p++;
}
void main()
{  clrscr();
   int x,y;
   x=y=0;
   for(int i=0;i<128;i++)
   {    show(i,i,x,y);
    y++;
    if(y>=80)
    {  x++;
       y=0;
    }
   }
   getch();
}

program of moving boundries

#include<conio.h>
#include<iostream.h>
void delay();
void bound1();
void bound2();
void bound3();
void bound4();
void bound5();
void line();
void main()
{ clrscr();
  for(int i=0;i<20;i++)
  {   bound1();
      delay();
      clrscr();
      bound2();
      delay();
      clrscr();
      bound3();
      delay();
      clrscr();
      bound4();
      delay();
      clrscr();
      bound5();
      delay();
      clrscr();
   }
 }
void bound1()
{   for(int i=0;i<9;i++)
    {    line();
     cout<<endl<<endl<<endl<<endl<<endl;
    }
    line();
}
void bound2()
{    cout<<endl;
     for(int i=0;i<9;i++)
     {   line();
     cout<<endl<<endl<<endl<<endl<<endl;
     }
     line();
}
void bound3()
{    cout<<endl<<endl;
     for(int i=0;i<9;i++)
     {  line();
    cout<<endl<<endl<<endl<<endl<<endl;
     }
     line();
}
void bound4()
{    cout<<endl<<endl<<endl;
     for(int i=0;i<9;i++)
     {  line();
    cout<<endl<<endl<<endl<<endl<<endl;
     }
     line();
}
void bound5()
{    cout<<endl<<endl<<endl<<endl;
     for(int i=0;i<9;i++)
     {  line();
    cout<<endl<<endl<<endl<<endl<<endl;
     }
     line();
}
void line()
{   for(int i=0;i<24;i++)
    cout<<"*";
    for(i=0;i<30;i++)
    cout<<" ";
    for(i=0;i<25;i++)
    cout<<"*";
}
void delay()
{   for(double j=0;j<7000000;j++)
    {}
}

program of loading 2

#include<iostream.h>
#include<conio.h>
void diley();
void line();
void mov();
void sp10();
void sp20();
void sp30();
void sp40();
void sp50();
void load();
void stop();
void main()
{
for(int u=0;u<10;u++)
 {
 load();
 line();
 mov();
 diley();
 clrscr();
 load();
 line();
 sp10();
 mov();
 diley();
 clrscr();
 load();
 line();
 sp20();
 mov();
 diley();
 clrscr();
 load();
 line();
 sp30();
 mov();
 diley();
 clrscr();
 load();
 line();
 sp40();
 mov();
 diley();
 clrscr();
 load();
 line();
 sp50();
 mov();
 diley();
 clrscr();
 }

 }

void diley()
{for(double m=0;m<20000000;m++)
{}
}
void line()
{  for(int k=0;k<25;k++)
  cout<<"_";
  cout<<endl;
  cout<<"                 ";    }
void sp10()
{  for( int l=0;l<5;l++)
   cout<<" ";
 }
void sp20()
{  for( int l=0;l<10;l++)
   cout<<" ";
 }
void sp30()
{  for( int l=0;l<15;l++)
   cout<<" ";
 }
void sp40()
{  for( int l=0;l<20;l++)
   cout<<" ";
 }
void sp50()
{  for( int l=0;l<25;l++)
   cout<<" ";
 }
 void mov()
 { cout<<"|";
 }
 void load()
 {   cout<<endl<<endl<<endl<<endl<<endl;
     cout<<"               loading your persional setting"<<endl<<endl;
     cout<<"                  ";
  }
 void stop()
 {cout<<"your project is opened";
  getch();
 }

program of loading

#include<iostream.h>
#include<conio.h>
void delay();
void mark();
void main()
{ clrscr();
  cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n                       loading your persional setting";
  cout<<"\n\n                     ==================================";
  cout<<"\n                     ";
  for(int i=0;i<34;i++)
  { mark();
    delay();
  }
  getch();
  }
  void delay()
  { for(double i=0;i<30000000;i++)
    {}
  }
  void mark()
  {  cout<<"|";
  }

program to print menu without using inbuilt functions

#include<iostream.h>
#include<conio.h>
void insert();
void main()
{  char far*p=(char far*)0xb8000000;
   char far*g=p;
   int a;
   char ch[][7]={"MENU","Item 1","Item 2","Item 3","Item 4"};
   clrscr();
   a=6;
   p+=3*160+33*2;
   *p=218;
   p++;
   *p=a;
   p++;
   for(int i=0;i<8;i++)
   {  *p=196;
      p++;
      *p=a;
      p++;
   }
   *p=191;
   p++;
   *p=a;
   p++;
   p=g;
   p+=9*160+34*2;
   for(i=0;i<8;i++)
   {  *p=196;
      p++;
      *p=a;
      p++;
   }
   p=g;
   p+=19*160+34*2;
   for(i=0;i<8;i++)
   {  *p=196;
      p++;
      *p=a;
      p++;
   }

   for(i=0;i<16;i++)
   {  p=g;
      p+=(i+4)*160+33*2;
      if(i==5)
      {  *p=195;
     p++;
     *p=a;
     p++;
     continue;
      }

      if(i==15)
      {  *p=192;
     p++;
     *p=a;
     p++;
     continue;
      }
      *p=179;
      p++;
      *p=a;
      p++;
  }

  for(i=0;i<16;i++)
   {  p=g;
      p+=(i+4)*160+42*2;
      if(i==5)
      {  *p=180;
     p++;
     *p=a;
     p++;
     continue;
      }

      if(i==15)
      {  *p=217;
     p++;
     *p=a;
     p++;
     continue;
      }
      *p=179;
      p++;
      *p=a;
      p++;
  }
    p=g;
    p+=6*160+36*2;
    for(i=0;i<4;i++)
    { *p=ch[0][i];
      p++;
      *p=a;
      p++;
    }
    int k=0;
    for(i=1;i<5;i++)
    {   p=g;
    p+=(k+11)*160+35*2;
    for(int j=0;j<6;j++)
    {  *p=ch[i][j];
       p++;
       *p=a;
       p++;
    }
    k+=2;
   }

  getch();
}

program to print rectangular bowl without using in built function

#include<iostream.h>
#include<conio.h>
void main()
{  clrscr();
   char far*p=(char far*)0xb8000000;
   char far*g=p;
   int a;
   a=2;
   p+=4*160+25*2;
   for(int i=0;i<9;i++)
   {  *p=196;
      p++;
      *p=a;
      p++;
   }
   *p=191;
   p++;
   *p=a;
   p++;
   for(i=0;i<9;i++)
   {  *p=32;
      p++;
      *p=a;
      p++;
   }
   *p=218;
   p++;
   *p=a;
   p++;
    for(i=0;i<9;i++)
   {  *p=196;
      p++;
      *p=a;
      p++;
   }

   for(i=0;i<15;i++)
   {   p=g;
       p+=(i+5)*160+(34*2);
       *p=179;
       p++;
       *p=a;
       p++;
       for(int j=0;j<9;j++)
       {   *p=32;
        p++;
       *p=4;
       p++;
       }

       *p=179;
       p++;
       *p=a;
       p++;
   }
  p=g;
  p+=20*160+34*2;
  *p=192;
  p++;
  *p=a;
  p++;

   for(i=0;i<9;i++)
   {   *p=196;
       p++;
       *p=a;
       p++;
   }
   *p=217;
   p++;
   *p=a;
   p++;
   getch();
   }

program to print rectangle without using inbuilt function

#include<iostream.h>
#include<conio.h>
void main()
{  clrscr();
   char far*p=(char far*)0xb8000000;
   char far*g=p;
   int a;
   a=2;
   p+=4*160+30*2;
   *p=218;
   p++;
   *p=a;
   p++;
   for(int i=0;i<15;i++)
   {   *p=196;
       p++;
       *p=a;
       p++;
   }
   *p=191;
   p++;
   *p=a;
   p++;
   p=g;
   for(i=0;i<15;i++)
   {   p=g;
       p+=(i+5)*160+(30*2);
       *p=179;
       p++;
       *p=a;
}
}