[HEADER]
Credits:
Original Design by
Prof.  Rasala, Prof.  Fell and Prof. Proulx.

Port of IOTools and MathUtils to VC++ by Prof. Rasala

Port of Windows and Graphics functions to VC++ by Sergey Bratus

Delay Commands:
- Delay

Graphic Commands:
- SetForeColor
- MakePoint
- MakeRect
- SetPoint
- SetRect
- GetPoint
- GetRect
- PaintCircle
- FrameCircle
- PaintRect
- FrameRect
- ClearDrawing
- MoveTo
- LineTo
- Move
- Line
- SetColorPixel
- GetColorPixel
- ShowString

Mouse Functions:
- Button
- GetMouse
- GetClickPoint

IO Tools Commands:
- SetCaseAction
- GetCaseAction
- PromptAnswer
- RequestString
- ReadingString
- InputError

 

 

"ct_delay.h" - Delay Commands:
void Delay( int ticks ) ;
Delay the program for a specified number of ticks.  One tick is 1/60 of a second.

eg. Delay(60); // one second
     Delay(3600); //one minute


"ct_graphics.h" - Graphics Commands:

void SetForeColor( int r, int g, int b );
Set the foreground color to (red,green,blue). Each component can range between 0-255. 0 is darkest color.

eg. SetForeColor(0,0,0);        // will set pen to black
      SetForeColor(0,255,0);   // will set pen to green

Functions to handle the standard Mac graphics library structs Point and Rect. The definitions of these structs are

struct Point {
    int h;
    int v;
};

struct Rect {
    int left;
    int top;
    int right;
    int bottom;
};

Point MakePoint( int x, int y );
Return a newly made Mac struct Point with coordinates (x,y).

Rect MakeRect( int x1, int y1, int x2, int y2 );
Return a newly made Mac struct Rect with the corners (x1,y1), (x2,y2).

void SetPoint( Point& p, int x, int y);
Set the struct Point p to have the cooordinates (x,y).

void SetRect( Rect& r, int x1, int y1, int x2, int y2 );
Set the struct Rect r to have the corners (x1,y1), (x2,y2).

void GetPoint( Point p, int& x, int& y);
Set the integer variables x, y to the coordinates of the struct Point p.

void GetRect( Rect r, int& x1, int& y1, int& x2, int& y2 );
Set the integer variables x1,y1,x2,y2 to the coordinates of the rectangle r.

 

void PaintCircle( int x, int y, int r );
Draw a filled (solid) circle with the center at (x,y) with the radius r.

void PaintCircle( Point p, int r );
Draw a filled (solid) circle with the center at the point p with the radius r.

void FrameCircle( int x, int y, int r );
Draw a frame ("wire") empty circle with the center at (x,y) with the radius r.

void FrameCircle( Point p , int r );
Draw a frame ("wire") empty circle with the center at p with the radius r.

 

void PaintRect( int x1, int y1, int x2, int y2 );
Paint a filled rectangle with the corners (x1,y1), (x2,y2).

void PaintRect( Rect r );
Paint a filled (solid) rectangle.

void FrameRect( int x1, int y1, int x2, int y2 );
Paint a frame ("wire") rectangle with the corners (x1,y1), (x2,y2).

void FrameRect( Rect r );
Paint a frame ("wire") rectangle.

 

void ClearDrawing( );
Clear the drawing window.

void MoveTo( int x, int y );
Move pen to the point with coordinates (x,y).

void MoveTo( Point p );
Move pen to the point with coordinates (x,y).

void LineTo( int x, int y );
Draw a line between the current point and the point with coordinates (x,y).

void LineTo( Point p );
Draw a line between the current point and the point with coordinates (x,y).

void Move( int x, int y );
Move the pen to the position (x,y) relative to the current point. Remembers the pen position as our current point.

void Line( int x, int y );
Draw a line from the current position to the position (x,y) relative to the current point.

 

void SetColorPixel( int x, int y, short r, short g, short b );
Set the pixel at  specified x and y coordinates to red (0-255),  green (0-255), blue (0-255)

void SetColorPixel( int x, int y, RGB(r, g, b) );
Set the pixel at  specified x and y coordinates to the specified RGB color. Unlike CoreTools, RGB is a macro in Win32.

void GetColorPixel( int x, int y, int& r, int& g, int& b );
Pick up the RGB color code of the pixel at the coordinates (x,y). 

 

void ShowString( const string & );
Display a string of text in the graphics window at the current pen position. Use MoveTo to position the pen.


"ct_mouse.h" - Mouse Related Commands:

bool Button();
Checks whether the mouse button is up or down (pressed or not). Return true if button is down, false otherwise.

void GetMouse( int& x, int& y );
Set the integer variables x and y to the current coordinates of the mouse pointer. Does not wait for the button to be pressed or released.

void GetMouse( Point& p );
Set the struct Point p to the current coordinates of the mouse pointer.

void GetClickPoint( Point& UpSpot );
Wait for the mouse button to be pressed and released (i.e. for a mouse click). Set UpSpot to the coordinates of the point where the mouse button was released.


"IOTools.h" - IO Tools Commands:

void SetCaseAction(CaseAction action);

void GetCaseAction(CaseAction& action);

void PromptAnswer(const string&  prompt,   const string& answer);

void RequestString(const string&   prompt,   const string&    answer,    string&  response);

int ReadingString(const string&     prompt,  string&  response);

bool InputError();

bool InputErrorVerbose() {&    prompt,     const string&    answer);

void GetOneLine(string& s)

void GetOneLine(char* buffer, int room)

void SkipPastNewline()

void ChangeCase(char* s, CaseAction action)

void SquashString(char* s)

void SkipSpace(const char*& s)

void SkipWhile(const char*& s, IntFcnPtr Test)

... To be Completed


"MathUtil.h" - Math Toolkit Commands:

int SafeRoundToInt(double d);
SafeRoundToInt returns x safely rounded to an integer.

long SafeRoundToLong(double d);
SafeRoundToLong returns x safely rounded to a long integer.


// Radians to Degrees Conversions
const double pi = 3.14159265358979324;
const double radians_to_degrees = 180 / pi;
const double degrees_to_radians = pi / 180;

The following functions accept their argument in degrees. The standard library functions sin, cos, tan etc. assume that the argument is in radians.

double sindeg(double x);

double cosdeg(double x);

double tandeg(double x);

double asindeg(double x);

double acosdeg(double x);

double atandeg(double x);

... To be Completed