Header file:
graphics.h
Synopsis:
void cleardevice (void);
Description:
cleardevice() clears the whole graphic screen and resets the current position to (0,0).
cleardevice function in c graphics
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
int main(void) {
/* request auto detection */
int graphicDriver = DETECT, graphicMode;
int err, x, y;
/* initialize graphics and local variables */
initgraph(&graphicDriver, &graphicMode,
"C:/TURBOC3/BGI");
/* read result of initialization */
err = graphresult();
if (err != grOk) {
/* an error occurred */
printf("Graphic Error: %s\n",
grapherrormsg(err));
return 0;
}
x = getmaxx() / 2;
y = getmaxy() / 2;
/* output a message to the screen */
circle(x, y, 100);
delay(700);
setcolor(10);
settextjustify(CENTER_TEXT, CENTER_TEXT);
/* prints CLEAR SCREEN at the given position(x, y) */
outtextxy(x, y, "CLEAR SCREEN");
delay(700);
/* clears the screen */
cleardevice();
getch();
/* deallocates memory allocated for graphic screen */
closegraph();
return 0;
}
Output: (cleardevice built-in function in c graphics.h)
No comments:
Post a Comment