BGI graphics library And Visual Studio Layout of graphics window X increasing 0, 0 Y i n c r e a s i n g 639, 479 Prolog required for every graphics program #include “graphics.h” - same place as other includes AND inside main() start graphics code with initwindow (x, y); // x is the number of pixels horizontally // and y is the number of pixels vertically or initwindow (x, y, string); // where string is the title to go in // the title bar of the graphics window Required at end of program closegraph(); usually right before return 0; if you want to pause the graphics window you can use getch(); this is a function that will get a character from the keyboard and discard it Functions x = getmaxx(); y = getmaxy(); return the highest x value and y value possible in the current graphics mode These can be useful if you want something centered in the window putpixel (x/2, y/2, RED); would put a tiny red dot in the middle of the window To pause the program getch(); strictly this does return the character that was pressed on the keyboard, but for this use we do not care what character was pressed. So the function can be called as a “void” function, i.e. on a line by itself More Functions - Color void setcolor (int color); color used to draw with void setfillpattern (SOLID_FILL, BLUE); will cause any 'filled' or 'bar' calls after that to fill in solidly with blue BLUE, GREEN, CYAN, RED and so on are named constants (actually integers) that you can use as color arguments; SOLID_FILL, LINE_FILL, SLASH_FILL are the same for fill patterns More functions void line (int x1, int y1, int x2, int y2 ); draws a line from (x1, y1) to (x2, y2) line (25, 50, 35, 50); // horizontal void rectangle (int left, int top, int right, int bottom); rectangle (150, 200, 400, 350); // a box that is 250 pixels wide and 150 tall Another function outtextxy(x, y, "This is a test."); (x,y) is where the text will start on the screen if you want to pass a string variable to this function, you must use outtextxy (x, y, const_cast<char*>(str.c_str())); where str is the name of the string variable