Header file:
graphics.h
Synopsis:
void graphdefaults();
Description:
graphdefaults() resets all graphics setting(view port, current, background color, drawing color, palette, fill color, fill style, text style etc) to default values.
graphdefaults function in c graphics
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void) {
/* request auto detection */
int graphicDriver = DETECT, graphicMode;
int err, midx, midy;
/* 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));
getch();
return 0;
}
/* mid position in x and y axis */
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* sets text justification */
settextjustify(CENTER_TEXT, CENTER_TEXT);
/* outputs text at the given point */
outtextxy(midx, 50, "Circle with custom settings");
/* draw a circle using the current draw color */
setcolor(10);
setfillstyle(SLASH_FILL, 10);
circle(midx, midy, 150);
floodfill(midx, midy, 10);
getch();
/* restore default values for everything */
graphdefaults();
/* clear the screen */
cleardevice();
/* output line with default settings */
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(midx, 50, "Circle with default settings");
/* draw a circle with radius 150 */
circle(midx, midy, 150);
/* clean up */
getch();
closegraph();
return 0;
}
Output: (graphdefaults built-in function in c graphics.h)
No comments:
Post a Comment