Loading page and hexagonal pattern using c/c++ and graphics
Hey guys, here is the simple code to illustrate the loading of the page. We have seen like million times when we open some page it takes time to load and in that time they show that they are loading by using blinking circles or bars filling up to 100% and so on. In this code I have demonstrated how we can use same technique. After the compiler is done loading the page just press any key and hexagonal pattern will be formed using graphics. Hope you guys like it. Here's the screen shot of the output.
Here's the code. Enjoy coding...
Note: If the code is generating error in c then please save the file with .cpp extension.
/*
Programmer: Ashok Kumar Shrestha (ak007)
Program details: Loading page and Hexagonal pattern
*/
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<stdlib.h>
#include<math.h>
Programmer: Ashok Kumar Shrestha (ak007)
Program details: Loading page and Hexagonal pattern
*/
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<stdlib.h>
#include<math.h>
void loading();
void hexagon(int ,int,int,int color);
void pattern();
void hexagon(int ,int,int,int color);
void pattern();
void main()
{
int i,j,k,l,m,n;
int gd=DETECT,gm,button;
initgraph(&gd,&gm,"..\\bgi");
cleardevice();
loading();
cleardevice();
pattern();
getch();
closegraph();
}
{
int i,j,k,l,m,n;
int gd=DETECT,gm,button;
initgraph(&gd,&gm,"..\\bgi");
cleardevice();
loading();
cleardevice();
pattern();
getch();
closegraph();
}
void loading()
{
int d=3,i,x1=120,y1=350,x2=x1+400,y2=y1+15;
char arr[10];
cleardevice();
moveto(260,50);
setcolor(7);
settextstyle(4,0,10);
outtext("A");
settextstyle(1,0,1);
moveto(250,200);
outtext("PRODUCTION");
delay(600);
setcolor(1);
setfillstyle(1,3);
rectangle(x1,y1,x2,y2);
rectangle(x1-d,y1-d,x2+d,y2+d);
floodfill(x1-1,y1-1,1);
setcolor(7);
settextstyle(8,0,1);
outtextxy(x1,y1-30,"Loading...");
setfillstyle(1,2);
for(i=0;i<100;i++)
{
delay(100);
bar(x1+1,y1+1,x1+i*4+3,y2-1);
gotoxy(x2/8-2,y1/17+1);
printf("%d %",i+1);
}
getch();
}
{
int d=3,i,x1=120,y1=350,x2=x1+400,y2=y1+15;
char arr[10];
cleardevice();
moveto(260,50);
setcolor(7);
settextstyle(4,0,10);
outtext("A");
settextstyle(1,0,1);
moveto(250,200);
outtext("PRODUCTION");
delay(600);
setcolor(1);
setfillstyle(1,3);
rectangle(x1,y1,x2,y2);
rectangle(x1-d,y1-d,x2+d,y2+d);
floodfill(x1-1,y1-1,1);
setcolor(7);
settextstyle(8,0,1);
outtextxy(x1,y1-30,"Loading...");
setfillstyle(1,2);
for(i=0;i<100;i++)
{
delay(100);
bar(x1+1,y1+1,x1+i*4+3,y2-1);
gotoxy(x2/8-2,y1/17+1);
printf("%d %",i+1);
}
getch();
}
void hexagon(int d,int stta,int etta,int color)
{
int i,j,mx=320,my=230,x[6],y[6];
struct arccoordstype arcinfo;
for(i=0;i<6;i++)
{
setcolor(0);
arc(mx,my,stta+60*i,etta+60*i,d);
getarccoords(&arcinfo);
x[i]=arcinfo.xend;
y[i]=arcinfo.yend;
setcolor(color);
}
for(i=0;i<5;i++)
{
line(x[i],y[i],x[i+1],y[i+1]);
}
line(x[5],y[5],x[0],y[0]);
}
{
int i,j,mx=320,my=230,x[6],y[6];
struct arccoordstype arcinfo;
for(i=0;i<6;i++)
{
setcolor(0);
arc(mx,my,stta+60*i,etta+60*i,d);
getarccoords(&arcinfo);
x[i]=arcinfo.xend;
y[i]=arcinfo.yend;
setcolor(color);
}
for(i=0;i<5;i++)
{
line(x[i],y[i],x[i+1],y[i+1]);
}
line(x[5],y[5],x[0],y[0]);
}
void pattern()
{
int i,j,k;
setcolor(9);
for(i=0;i<17;i++)
{
hexagon(i*10,45+i*10,80+i*10,3);
// hexagon(i*10,0,180);// for regular eqidistance hexagon. vary last angle to obtain hexagon oreinted in different direction.
delay(50);
}
}
//End of the program
{
int i,j,k;
setcolor(9);
for(i=0;i<17;i++)
{
hexagon(i*10,45+i*10,80+i*10,3);
// hexagon(i*10,0,180);// for regular eqidistance hexagon. vary last angle to obtain hexagon oreinted in different direction.
delay(50);
}
}
//End of the program
Comments
Post a Comment