graphics

graphics - we do not care what character was pressed. So...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
BGI graphics library And Visual Studio
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Layout of graphics window 0, 0 639, 479 X increasing Y i n c r e a s i n g
Background image of page 2
Prolog required for every graphics program #include “graphics.h” - same place as other includes AND inside main() /* request autodetection */ int gdriver = DETECT, gmode, errorcode; /* initialize graphics mode */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { cout << "Graphics error: " << grapherrormsg(errorcode) << endl; return 1; }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Required at end of program closegraph(); usually right before return 0;
Background image of page 4
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
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
To pause the program getch(); strictly this does return the character that was pressed on the keyboard, but for this use
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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, &quot;This is a test.&quot;); (x,y) is where the text will start on the screen...
View Full Document

This note was uploaded on 04/13/2011 for the course CS 115 taught by Professor Staff during the Fall '08 term at Kentucky.

Page1 / 9

graphics - we do not care what character was pressed. So...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online