You are here

graphdefaults function in c

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

  1. #include <graphics.h>
  2. #include <conio.h>
  4. main()
  5. {
  6.    int gd = DETECT, gm;
  8.    initgraph(&gd, &gm, "C:\\TC\\BGI");
  10.    setcolor(RED);
  11.    setbkcolor(YELLOW);
  13.    circle(250, 250, 50);
  15.    getch();
  16.    graphdefaults();
  18.    getch();
  19.    closegraph();
  20.    return 0;
  21. }

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.