请问: cleardevice()在程序中如何使用?

syany 2008-08-07 04:45:03
在程序中看到有时用在 initgraph() 的后面,

具体方法如何,请高手指点!谢谢
...全文
2595 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyn1987 2008-08-19
  • 打赏
  • 举报
回复
画图前一般需清除屏幕,使得屏幕如同一张白纸,以画最新最美的图画,因而必须使用
清屏函数,也就是说将屏幕上的内容全部清除。清屏函数的原型是:
void far cleardevice(void);该函数作用范围为整个屏幕
如果用函数setviewport 定义一个图视窗口,则可用清除图视
口函数,它仅清除图视口区域内的内容,该函数的说明原型是:
void far clearviewport(void);
就是这么简单!
NKLoveRene 2008-08-08
  • 打赏
  • 举报
回复
百度一下就都有了
1楼贴的就是百度第一条,hoho
aomeng 2008-08-07
  • 打赏
  • 举报
回复
函数名: cleardevice
功 能: 清除图形屏幕
用 法: void far cleardevice(void);
程序例:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;

/* initialize graphics and local variables */
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); /* terminate with an error code */
}

midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());

/* for centering screen messages */
settextjustify(CENTER_TEXT, CENTER_TEXT);

/* output a message to the screen */
outtextxy(midx, midy, "press any key to clear the screen:");

/* wait for a key */
getch();

/* clear the screen */
cleardevice();

/* output another message */
outtextxy(midx, midy, "press any key to quit:");

/* clean up */
getch();
closegraph();
return 0;
}

70,017

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧