Header file:
graphics.h
Synopsis:
void clearviewport();
Description:
clearviewport() clears the current view port and resets the current position to (0, 0), relative to the current view port.
clearviewport function in c graphics
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#define CLIP_ON 1 /* activates clipping in viewport */
int main(void) {
/* request auto detection */
int graphicDriver = DETECT, graphicMode;
int err, i;
/* 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;
}
setcolor(getmaxcolor());
/* message in default full-screen viewport */
outtextxy(0, 0, "Default viewport(0, 0)");
/* create a smaller viewport */
setviewport(50, 50, getmaxx()-50, getmaxy()-50, CLIP_ON);
/* draw arcs in current viewport */
for (i = 1; i < 200; i = i + 2) {
arc(0, 0, 245, 360, i);
delay(200);
}
/* clears the current viewport */
clearviewport();
/* output another message */
outtextxy(0, 0, "Cleared Sub View Port(0, 0)!!");
/* clean up */
getch();
closegraph();
return 0;
}
Output: (clearviewport built-in function in c graphics.h)
No comments:
Post a Comment