graphdefaults function resets all graphics settings to their defaults.
Declaration: void graphdefaults();
It resets the following graphics settings :-
- Sets the viewport to the entire screen.
- Moves the current position to (0,0).
- Sets the default palette colors, background color, and drawing color.
- Sets the default fill style and pattern.
- Sets the default text font and justification.
C programming source code for graphdefaults
#include <conio.h>
main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TC\\BGI");
setcolor(RED);
setbkcolor(YELLOW);
circle(250, 250, 50);
getch();
graphdefaults();
getch();
closegraph();
return 0;
}
In the above program we have first changed the drawing color to RED and background color to YELLOW and then drawn a circle with (250, 250) as center and 50 as radius. When the user will press a key graphdefaults is called and both drawing and background color will be reset to their default values i.e. WHITE and BLACK respectively. See colors in C graphics.