gwindow.h

This file defines the GWindow class which supports drawing graphical objects on the screen.
Class
GWindow This class represents a graphics window that supports simple graphics.
Functions
convertColorToRGB(colorName) Converts a hexadecimal "#rrggbb" color name into an integer that encodes the red, green, and blue components of the color.
convertRGBToColor(rgb) Converts an rgb value into a hexadecimal color name in the form "#rrggbb".
exitGraphics() Closes all graphics windows and exits from the application without waiting for any additional user interaction.
getScreenHeight() Returns the height of the entire display screen.
getScreenSize() Returns the width/height of the entire display screen.
getScreenWidth() Returns the width of the entire display screen.
pause(milliseconds) Pauses for the indicated number of milliseconds.
repaint() Issues a request to update all graphics windows.
waitForClick() Waits for a mouse click to occur anywhere in any window.

Function detail


void repaint();
Issues a request to update all graphics windows. This function is called automatically when the program pauses, waits for an event, waits for user input on the console, or terminates. As a result, most clients never need to call repaint explicitly.

Usage:

repaint();

void pause(double milliseconds);
Pauses for the indicated number of milliseconds. This function is useful for animation where the motion would otherwise be too fast.

Usage:

pause(milliseconds);

double getScreenWidth();
Returns the width of the entire display screen.

Usage:

width = getScreenWidth();

double getScreenHeight();
Returns the height of the entire display screen.

Usage:

height = getScreenHeight();

GDimension getScreenSize();
Returns the width/height of the entire display screen.

Usage:

GDimension size = getScreenSize();

int convertColorToRGB(string colorName);
Converts a color name into an integer that encodes the red, green, and blue components of the color. The color is represented in the 32-bit integer in the following way, from most-significant to least-significant bit:

For example, the call of convertColorToRGB("#ff00ff") would return the integer value 0xff00ff, which is 16711935 in base-10.

Usage:

int rgb = convertColorToRGB(colorName);

string convertRGBToColor(int rgb);
Converts an rgb value into a color name in the form "#rrggbb". Each of the rr, gg, and bb values are two-digit hexadecimal numbers indicating the intensity of that component, from 00 (the least amount of that color) to ff, the hexadecimal representation of the number 255, indicating the largest amount of that color.

Colors are usually written as hexadecimal (base-16) integer literal values. For example, the color black is represented as 0x000000, white is 0xffffff, red is 0xff0000, green is 0x00ff00, blue is 0x0000ff, purple is 0xff00ff, yellow is 0xffff00, and so on.

For example, the call of convertRGBToColor(0xff00cc) would return the string "#ff00ff".

Usage:

string colorName = convertRGBToColor(rgb);

void waitForClick();
Waits for a mouse click to occur anywhere in any window.

Usage:

waitForClick();

void exitGraphics();
Closes all graphics windows and exits from the application without waiting for any additional user interaction.

Usage:

exitGraphics();