📄 gui.c
字号:
#include <graphics.h>
void c_box(unsigned int wait_time,unsigned int ccolor)
{
unsigned int cx,cy;
cx=320;
cy=240;
setcolor(ccolor);
do
{
rectangle(320-cx,240-cy,320+cx,240+cy);
if(cx>0) {cx--;}
if(cy>0) {cy--;}
pwait(wait_time);
}
while((cx>0)||(cy>0));
setcolor(YELLOW);
}
void e_box(unsigned int center_x, unsigned int center_y, unsigned int length, unsigned int height)
{
unsigned int left, right;
unsigned int top, bottom;
unsigned int cx,cy;
cx=0;
cy=0;
do
{
setcolor(WHITE);
rectangle(center_x-cx,center_y-cy,center_x+cx,center_y+cy);
setcolor(DARKGRAY);
rectangle(center_x-cx+1,center_y-cy+1,center_x+cx-1,center_y+cy-1);
setcolor(WHITE);
rectangle(center_x-cx+2,center_y-cy+2,center_x+cx-2,center_y+cy-2);
setcolor(BLUE);
rectangle(center_x-cx+3,center_y-cy+3,center_x+cx-3,center_y+cy-3);
if(cx<length/2) {cx++;}
if(cy<height/2) {cy++;}
}
while((cx<length/2)||(cy<height/2));
setcolor(YELLOW);
}
void gui(void)
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
/* 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); /* return with error code */
}
settextstyle(SMALL_FONT, HORIZ_DIR, 1);
setcolor(YELLOW);
setbkcolor(BLUE);
}
void fubar(unsigned char mode, unsigned int cur, unsigned int max)
{
unsigned int cnt;
unsigned int initx=320,inity=456;
unsigned int length=580,height=16;
unsigned int border=10;
if(mode==1)
{
e_box(initx,inity,length+border,height+border);
}
cnt=((float)cur/(float)max)*length;
line(initx-length/2+cnt,inity-height/2,initx-length/2+cnt,inity+height/2);
}
void close_gui(void)
{
closegraph();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -