1 / 12

C++ Graphics Primitives

C++ Graphics Primitives. April 15th. void clearscreen(int c) clear the screen to background color c If c <= 0 screen white If c >= 1 screen black. void moveto(int x, int y) Cursor moves to position (x,y) (without drawing anything on the screen) The value x must be between 0 and maxX

braima
Download Presentation

C++ Graphics Primitives

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C++ Graphics Primitives April 15th

  2. void clearscreen(int c) • clear the screen to background color c • If c <= 0 screen white • If c >= 1 screen black

  3. void moveto(int x, int y) • Cursor moves to position (x,y) (without drawing anything on the screen) • The value x must be between 0 and maxX • The value y must be between 0 and maxY

  4. int getmaxx() Return the integer value of maxX for the screen int getmaxy() Return the integer value of maxX for the screen

  5. Example void main () { int x,y; x = getmaxx(); y = getmaxy(); moveto(x/2, y/2); }

  6. void setcolor(int c) • Set the color of the pen that will be drawing lines and shapes on screen to color c • If c <= 0 pen color white • If c >= 1 pen color black • Note: white pen on white screen (also black pen on black screen) will not show up (can be used to erase)

  7. void lineto(int x, int y) • Draw a straight line from current position of cursor to position (x,y) on screen using current pen color • Example: … clearscreen(0); //screen white setcolor(1); //pen black moveto(20,20); //move cursor to (20,20) lineto(100,100);

  8. void rectangle(int x1, int y1, int x2, int y2) • Draw a rectangle with upper left corner at position (x1, y1) and lower right corner (x2, y2)

  9. void circle(int x, int y, int r) • Draw a circle with center at (x,y) and radius r

  10. void writedraw(type value, int x, int y) - where type can be int, char or a text (string) - display the value at position (x,y) on screen Example: ... writedraw(3, 10, 10); writedraw(“Stop right here!!”, 100, 100); writedraw(‘a’, 25, 25); …

  11. void getmouse(int &x, int &y) • Get into x and y the current mouse coordinates at the instant when the mouse is clicked • Example: int x, y; getmouse(x,y); if (x <= 100 && y <= 100) { writedraw( “Bingo! You clicked in the upper left corner!”, 10, 10); } else { writedraw(“soryy…try again…”, 10, 10); }

  12. Click here to exit Stop!

More Related