📄 graphics.cpp
字号:
/*************************************************************************/
/*************************************************************************/
/**************************** GRAPHICS.CPP *****************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************
By :
Muhammad Tahir Shahzad [ MTS ]
B.C.S Honours [ 2000-04 ]
Government College University Lahore
Pakistan
E-mail : mtshome@wol.net.pk
Web-Site : www.mts-home.cjb.net [ www.wol.net.pk/mtshome ]
www.mtshome.cjb.net [ www.geocities.com/mtahirshahzad ]
*************************************************************************/
/*************************************************************************/
/*************************************************************************/
//--------------------------- Header Files ----------------------------//
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
//--------------------------- User Defined ----------------------------//
/*************************************************************************/
# include "Linklist.H"
/**************************************************************************/
/**************************************************************************/
//--------------------- FUNCTION DEFINITIONS ---------------------------//
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
//--------------------------- Graphics( ) -----------------------------//
/*************************************************************************/
Graphics::Graphics( )
{
fill_pattern[0]=0xAA;
fill_pattern[1]=0x55;
fill_pattern[2]=0xAA;
fill_pattern[3]=0x55;
fill_pattern[4]=0xAA;
fill_pattern[5]=0x55;
fill_pattern[6]=0xAA;
fill_pattern[7]=0x55;
}
/*************************************************************************/
//------------------ draw_line(int,int,int,int,int) -------------------//
/*************************************************************************/
void Graphics::draw_line(int x_1,int y_1,int x_2,int y_2,int IN_OUT,
int HORIZONTAL_VERTICAL)
{
if(HORIZONTAL_VERTICAL==HORIZONTAL)
{
if(IN_OUT==IN)
{
for(int count=0;count<5;count++)
{
if(count==0 || count==1)
setcolor(15);
else if(count==2 || count==3)
setcolor(7);
else if(count==4)
setcolor(8);
line(x_1+count,y_1+count,x_2-count,y_2+count);
}
}
else if(IN_OUT==OUT)
{
for(int count=0;count<5;count++)
{
if(count==0 || count==1)
setcolor(15);
else if(count==2 || count==3)
setcolor(7);
else if(count==4)
setcolor(8);
line(x_1+count,y_1-count,x_2-count,y_2-count);
}
}
}
else if(HORIZONTAL_VERTICAL==VERTICAL)
{
if(IN_OUT==IN)
{
for(int count=0;count<5;count++)
{
if(count==0 || count==1)
setcolor(15);
else if(count==2 || count==3)
setcolor(7);
else if(count==4)
setcolor(8);
line(x_1+count,y_1+count,x_2+count,y_2-count);
}
}
else if(IN_OUT==OUT)
{
for(int count=0;count<5;count++)
{
if(count==0 || count==1)
setcolor(15);
else if(count==2 || count==3)
setcolor(7);
else if(count==4)
setcolor(8);
line(x_1-count,y_1+count,x_2-count,y_2-count);
}
}
}
}
/*************************************************************************/
//--------------------- draw_arc(int,int,int,int) ---------------------//
/*************************************************************************/
void Graphics::draw_arc(int x,int y,int radius,int LEFT_RIGHT)
{
if(LEFT_RIGHT==RIGHT)
{
for(int count=0;count<5;count++)
{
if(count==0 || count==1)
setcolor(15);
else if(count==2 || count==3)
setcolor(7);
else if(count==4)
setcolor(8);
arc(x,y,270,90,radius-count);
}
}
else if(LEFT_RIGHT==LEFT)
{
for(int count=0;count<5;count++)
{
if(count==0 || count==1)
setcolor(15);
else if(count==2 || count==3)
setcolor(7);
else if(count==4)
setcolor(8);
arc(x,y,90,270,radius-count);
}
}
}
/*************************************************************************/
//-------------------- draw_button(int,int,char []) -------------------//
/*************************************************************************/
void Graphics::draw_button(int x_1,int y_1,char title[])
{
int x_2=x_1+(strlen(title)*9)+15;
int y_2=y_1+28;
int radius=14;
draw_line(x_1-2,y_1,x_2+2,y_1,IN,HORIZONTAL);
draw_line(x_1-2,y_2,x_2+2,y_2,OUT,HORIZONTAL);
draw_arc(x_1,y_1+radius,radius,LEFT);
draw_arc(x_2,y_1+radius,radius,RIGHT);
setcolor(6);
setfillstyle(1,6);
bar(x_1,y_1+5,x_2,y_2-5);
pieslice(x_1,y_1+radius,0,360,radius-5);
pieslice(x_2,y_1+radius,0,360,radius-5);
settextstyle(2,0,6);
setcolor(0);
outtextxy(x_1+3,y_1+4,title);
outtextxy(x_1+4,y_1+4,title);
setcolor(14);
outtextxy(x_1+5,y_1+3,title);
outtextxy(x_1+6,y_1+3,title);
}
/*************************************************************************/
//------------------- hilight_button(int,int,char []) -----------------//
/*************************************************************************/
void Graphics::hilight_button(int x_1,int y_1,char title[],int color )
{
int x_2=x_1+(strlen(title)*9)+15;
int y_2=y_1+28;
int radius=14;
setcolor(color);
setfillstyle(1,color);
bar(x_1,y_1+5,x_2,y_2-5);
pieslice(x_1,y_1+radius,0,360,radius-5);
pieslice(x_2,y_1+radius,0,360,radius-5);
settextstyle(2,0,6);
setcolor(0);
outtextxy(x_1+3,y_1+4,title);
outtextxy(x_1+4,y_1+4,title);
setcolor(14);
outtextxy(x_1+5,y_1+3,title);
outtextxy(x_1+6,y_1+3,title);
}
/*************************************************************************/
//----------------------- show_main_screen( ) -------------------------//
/*************************************************************************/
void Graphics::show_main_screen( )
{
cleardevice( );
for(int count_3=0;count_3<340;count_3+=20)
{
setfillpattern(fill_pattern,9);
bar(getmaxx( )/2-count_3,getmaxy( )/2-count_3,
getmaxx( )/2+count_3,getmaxy( )/2+count_3);
delay(1);
}
delay(100);
for(int count_=0;count_<5;count_++)
{
setcolor(0);
rectangle(count_,count_,getmaxx( )-count_,getmaxy( )-count_);
}
for(int count_4=0;count_4<=10;count_4++)
{
setlinestyle(0,0,3);
if(count_4==0)
{
setcolor(15);
setlinestyle(1,0,3);
}
else if(count_4==1 || count_4==2 || count_4==3 || count_4==4)
setcolor(15);
else if(count_4==5 || count_4==6 || count_4==7 || count_4==8)
setcolor(7);
else if(count_4==9 || count_4==10)
setcolor(8);
rectangle(5+count_4,5+count_4,(getmaxx( )-5)-count_4,
(getmaxy( )-5)-count_4);
delay(10);
}
setlinestyle(0,0,0);
delay(500);
char expression[14][2]={"I","m","p","l","e","m","e","n","t","a","t",
"i","o","n"};
int x=40;
int y=50;
for(int count_5=0;count_5<14;count_5++)
{
settextstyle(2,0,9);
setcolor(0);
moveto(x-2,y+3);
outtext(expression[count_5]);
moveto(x-2,y+2);
outtext(expression[count_5]);
moveto(x-1,y+2);
outtext(expression[count_5]);
setcolor(14);
moveto(x,y);
outtext(expression[count_5]);
moveto(x+1,y);
outtext(expression[count_5]);
moveto(x+2,y);
outtext(expression[count_5]);
x=getx( );
delay(50);
}
delay(500);
char linked[6][7]={"d","ed","ked","nked","inked","Linked"};
for(int count_6=0;count_6<6;count_6++)
{
settextstyle(1,0,8);
setcolor(0);
outtextxy(77,123,linked[count_6]);
outtextxy(77,122,linked[count_6]);
outtextxy(78,122,linked[count_6]);
outtextxy(79,121,linked[count_6]);
setcolor(11);
outtextxy(80,120,linked[count_6]);
outtextxy(81,120,linked[count_6]);
outtextxy(82,120,linked[count_6]);
delay(150);
if(count_6<5)
{
setfillpattern(fill_pattern,9);
bar(70,140,300,200);
}
}
delay(500);
char list[4][5]={" L"," Li"," Lis","List"};
for(int count_7=0;count_7<4;count_7++)
{
settextstyle(1,0,8);
setcolor(0);
outtextxy(377,123,list[count_7]);
outtextxy(377,122,list[count_7]);
outtextxy(378,122,list[count_7]);
outtextxy(379,121,list[count_7]);
setcolor(11);
outtextxy(380,120,list[count_7]);
outtextxy(381,120,list[count_7]);
outtextxy(382,120,list[count_7]);
delay(150);
if(count_7<3)
{
setfillpattern(fill_pattern,9);
bar(370,140,540,200);
}
}
delay(200);
settextstyle(6,0,8);
setcolor(0);
outtextxy(314,43,"of");
outtextxy(314,42,"of");
outtextxy(315,42,"of");
outtextxy(316,41,"of");
setcolor(10);
outtextxy(317,40,"of");
outtextxy(318,40,"of");
outtextxy(319,40,"of");
delay(200);
for(int count_8=0;count_8<440;count_8++)
{
setcolor(11);
line(75,180,75+count_8,180);
line(75,185,75+count_8,185);
line(75,190,75+count_8,190);
delay(2);
}
setcolor(15);
settextstyle(0,0,1);
outtextxy(30,425,"CopyRights (C) 2000-02");
outtextxy(30,440,"Muhammad Tahir Shahzad");
draw_button(500,395,"Continue");
draw_button(500,430,"Exit ");
}
/*************************************************************************/
//--------------------- show_selection_screen( ) ----------------------//
/*************************************************************************/
void Graphics::show_selection_screen( )
{
setfillpattern(fill_pattern,9);
bar(18,18,getmaxx()-18,getmaxy()-18);
delay(500);
settextstyle(2,0,7);
setcolor(0);
outtextxy(298,52,"Implementation");
outtextxy(298,51,"Implementation");
outtextxy(299,51,"Implementation");
setcolor(14);
outtextxy(300,50,"Implementation");
outtextxy(301,50,"Implementation");
settextstyle(1,0,6);
setcolor(0);
outtextxy(337,83,"Linked List");
outtextxy(337,82,"Linked List");
outtextxy(338,82,"Linked List");
outtextxy(339,81,"Linked List");
setcolor(11);
outtextxy(340,80,"Linked List");
outtextxy(341,80,"Linked List");
outtextxy(342,80,"Linked List");
settextstyle(6,0,5);
setcolor(0);
outtextxy(496,42,"of");
outtextxy(496,41,"of");
outtextxy(497,41,"of");
setcolor(10);
outtextxy(498,40,"of");
outtextxy(499,40,"of");
outtextxy(500,40,"of");
setcolor(11);
line(335,120,620,120);
line(335,123,620,123);
line(335,126,620,126);
settextstyle(2,0,8);
setcolor(0);
outtextxy(23,202,"Select the implementation mode :");
outtextxy(23,201,"Select the implementation mode :");
outtextxy(24,201,"Select the implementation mode :");
setcolor(14);
outtextxy(25,200,"Select the implementation mode :");
outtextxy(26,200,"Select the implementation mode :");
draw_button(50,295," Stack (Simple) ");
draw_button(50,370," Double Ended Stack ");
draw_button(400,295," Queue (Simple) ");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -