📄 graphics.cpp
字号:
draw_button(400,370," Double Ended Queue ");
draw_line(40,344,605,344,OUT,HORIZONTAL);
draw_line(40,346,605,346,IN,HORIZONTAL);
draw_arc(323,345,50,RIGHT);
draw_arc(323,345,50,LEFT);
setcolor(6);
setfillstyle(1,6);
pieslice(323,345,0,360,45);
settextstyle(1,0,5);
setcolor(0);
outtextxy(290,310,"L");
outtextxy(291,309,"L");
outtextxy(298,327,"L");
outtextxy(299,326,"L");
setcolor(11);
outtextxy(292,308,"L");
outtextxy(300,325,"L");
settextstyle(2,0,6);
setcolor(0);
outtextxy(315,334,"inked");
outtextxy(316,334,"inked");
outtextxy(324,351,"ist");
outtextxy(325,351,"ist");
setcolor(11);
outtextxy(317,333,"inked");
outtextxy(318,333,"inked");
outtextxy(326,350,"ist");
outtextxy(327,350,"ist");
}
/*************************************************************************/
//----------------------- blink_linked_list( ) ------------------------//
/*************************************************************************/
void Graphics::blink_linked_list( )
{
for(int count=0;count<10;count++)
{
if(count%2==0)
{
setcolor(12);
setfillstyle(1,12);
pieslice(323,345,0,360,45);
}
else
{
setcolor(6);
setfillstyle(1,6);
pieslice(323,345,0,360,45);
}
settextstyle(1,0,5);
setcolor(0);
outtextxy(290,310,"L");
outtextxy(291,309,"L");
outtextxy(298,327,"L");
outtextxy(299,326,"L");
setcolor(11);
outtextxy(292,308,"L");
outtextxy(300,325,"L");
settextstyle(2,0,6);
setcolor(0);
outtextxy(315,334,"inked");
outtextxy(316,334,"inked");
outtextxy(324,351,"ist");
outtextxy(325,351,"ist");
setcolor(11);
outtextxy(317,333,"inked");
outtextxy(318,333,"inked");
outtextxy(326,350,"ist");
outtextxy(327,350,"ist");
delay(400);
}
}
/*************************************************************************/
//---------------- show_window(int,int,int,int,int) -------------------//
/*************************************************************************/
void Graphics::show_window(int x_1,int y_1,int x_2,int y_2)
{
setcolor(15);
rectangle(x_1,y_1,x_2,y_2);
rectangle(x_1+1,y_1+1,x_2-1,y_2-1);
setcolor(7);
rectangle(x_1+2,y_1+2,x_2-2,y_2-2);
rectangle(x_1+3,y_1+3,x_2-3,y_2-3);
rectangle(x_1+4,y_1+4,x_2-4,y_2-4);
setcolor(8);
rectangle(x_1+5,y_1+5,x_2-5,y_2-5);
rectangle(x_1+6,y_1+6,x_2-6,y_2-6);
rectangle(x_1+7,y_1+7,x_2-7,y_2-7);
}
/**************************************************************************/
//------------------------ waiting_for_input( ) ------------------------//
/**************************************************************************/
void Graphics::waiting_for_input( )
{
do
{
setfillstyle(1,4);
bar(51,440,99,445);
setfillstyle(1,10);
bar(101,440,149,445);
setfillstyle(1,1);
bar(151,440,199,445);
setfillstyle(1,14);
bar(201,440,249,445);
delay(300);
if(kbhit( ))
break;
setfillpattern(fill_pattern,9);
bar(51,440,99,445);
delay(150);
if(kbhit( ))
break;
bar(101,440,149,445);
delay(150);
if(kbhit( ))
break;
bar(151,440,199,445);
delay(150);
if(kbhit( ))
break;
bar(201,440,249,445);
delay(150);
if(kbhit( ))
break;
setfillstyle(1,4);
bar(51,440,99,445);
delay(150);
if(kbhit( ))
break;
setfillstyle(1,10);
bar(101,440,149,445);
delay(150);
if(kbhit( ))
break;
setfillstyle(1,1);
bar(151,440,199,445);
delay(150);
if(kbhit( ))
break;
setfillstyle(1,14);
bar(201,440,249,445);
}
while(!kbhit( ));
setfillpattern(fill_pattern,9);
bar(51,440,249,445);
}
/**************************************************************************/
//--------------------- show_push_pop_screen(int) ----------------------//
/**************************************************************************/
void Graphics::show_push_pop_screen(int NORMAL_WARNING)
{
int x_1;
int x_2;
int y_1;
int y_2;
if(NORMAL_WARNING==NORMAL)
{
x_1=20;
x_2=280;
y_1=277;
y_2=350;
}
if(NORMAL_WARNING==WARNING)
{
x_1=20;
x_2=280;
y_1=277;
y_2=367;
}
setcolor(15);
setlinestyle(1,0,3);
rectangle(x_1,y_1,x_2,y_2);
setlinestyle(0,0,0);
setcolor(15);
rectangle(x_1,y_1,x_2,y_2);
setcolor(7);
rectangle(x_1+1,y_1+1,x_2-1,y_2-1);
setcolor(8);
rectangle(x_1+2,y_1+2,x_2-2,y_2-2);
setfillstyle(1,9);
bar(x_1+3,y_1+3,x_2-3,y_2-3);
}
/**************************************************************************/
//--------------------- show_push_pop_screen(int) ----------------------//
/**************************************************************************/
void Graphics::show_insert_delete_screen(int NORMAL_WARNING)
{
show_push_pop_screen(NORMAL_WARNING);
}
/**************************************************************************/
//---------------------- show_element_screen(int) ----------------------//
/**************************************************************************/
void Graphics::show_stack_element_screen(int PUSH_POP)
{
show_push_pop_screen(NORMAL);
if(PUSH_POP==PUSH)
{
settextstyle(2,0,6);
setcolor(0);
outtextxy(28,281,"Enter the Element :");
setcolor(11);
outtextxy(29,280,"Enter the Element :");
outtextxy(30,280,"Enter the Element :");
}
else if(PUSH_POP==POP)
{
settextstyle(2,0,6);
setcolor(0);
outtextxy(28,281,"Poped Element is :");
setcolor(11);
outtextxy(29,280,"Poped Element is :");
outtextxy(30,280,"Poped Element is :");
}
delay(300);
for(int count=1;count<=65;count++)
{
setcolor(0);
setfillstyle(1,0);
bar(180-count,306,180+count,330);
pieslice(180-count,318,0,360,12);
pieslice(180+count,318,0,360,12);
setcolor(15);
line(180-count,302,180+count,302);
line(180-count,334,180+count,334);
arc(180-count,318,90,270,16);
arc(180+count,318,270,90,16);
setcolor(7);
arc(180-count,318,90,270,15);
arc(180-count,318,90,270,14);
line(180-count,303,180+count,303);
line(180-count,304,180+count,304);
line(180-count,333,180+count,333);
line(180-count,332,180+count,332);
arc(180+count,318,270,90,15);
arc(180+count,318,270,90,14);
setcolor(8);
line(180-count,305,180+count,305);
line(180-count,331,180+count,331);
arc(180-count,318,90,270,13);
arc(180+count,318,270,90,13);
delay(4);
}
}
/**************************************************************************/
//---------------------- show_element_screen(int) ----------------------//
/**************************************************************************/
void Graphics::show_queue_element_screen(int INSERT_DELETE)
{
show_stack_element_screen(INSERT_DELETE);
}
/**************************************************************************/
//------------------- clear_element_screen(int) ------------------------//
/**************************************************************************/
void Graphics::clear_element_screen(int NORMAL_WARNING)
{
if(NORMAL_WARNING==WARNING)
{
for(int count=1;count<=50;count++)
{
setfillpattern(fill_pattern,9);
bar(18,275,290,275+count);
bar(18,375,290,375-count);
delay(20);
}
}
else if(NORMAL_WARNING==NORMAL)
{
for(int count=1;count<=40;count++)
{
setfillpattern(fill_pattern,9);
bar(18,275,290,275+count);
bar(18,355,290,355-count);
delay(20);
}
}
}
/**************************************************************************/
//---------------------------- get_element( ) --------------------------//
/**************************************************************************/
long Graphics::get_element(int single_double_ended)
{
show_stack_element_screen(PUSH);
int count=0;
int input_digits;
if(single_double_ended==SINGLE)
input_digits=4;
else if(single_double_ended==DOUBLE)
input_digits=3;
char Number[6]={NULL};
Number[0]='0';
do
{
int key_code=0;
char key=NULL;
if(kbhit( ))
key=getch( );
key_code=int(key);
if(count==input_digits && key_code==13)
break;
else if(key_code>=48 && key_code<=57 && count<input_digits)
{
Number[count]=key;
count++;
}
else if(key_code==8 && count>0)
{
setfillstyle(1,0);
bar(130,306,230,330);
count--;
Number[count]=NULL;
}
else if(key_code==13 && count>0)
break;
else if(key_code==13 && Number[0]=='0')
break;
if(count==1)
{
setfillstyle(1,0);
bar(130,306,230,330);
}
setcolor(12);
settextstyle(2,0,7);
moveto(140,305);
outtext(Number);
moveto(141,305);
outtext(Number);
int x=getx( );
int y=305;
while(!kbhit( ))
{
settextstyle(2,0,7);
setcolor(12);
moveto(x+2,y);
outtext("_");
delay(250);
setcolor(0);
moveto(x+2,y);
outtext("_");
delay(200);
}
}
while(count<input_digits+2);
long element=atol(Number);
clear_element_screen(NORMAL);
return element;
}
/*************************************************************************/
/*************************************************************************/
/****************************** THE END ********************************/
/*************************************************************************/
/*************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -