GRAPHICS FUNCTIONS

advertisement
GRAPHICS FUNCTIONS
(Libraries: ccc_win.h, ccc_time.h)
Constructs a point at location
(x, y)
Point(x,y)
p.get_x()
Returns the x-coordinate of a
point p
p.get_y()
Returns the y-coordinate of a
point p
Constructs a line joining points
p and q
l.get_start()
Returns the starting point of
line l
l.get_end()
Returns the end point of line l
l.move(dx, dy)
Moves line l by (dx, dy)
Moves point by by (dx, dy)
p.move(dx,dy)
Message(p, s)
Line(p,q)
Constructs a message with starting
point p and text string s
Message(p, x)
Constructs a message with starting
point p and label equal to the
number x
m.get_start()
Returns the starting point of
message m.
m.get_text()
Gets the text string message m
m.move(dx, dy)
Moves message m by (dx, dy)
Circle(p, r)
Constructs a circle with center p
and radius r
c.get_center()
Returns the center point of a
circle c
c.get_radius() Returns the radius of a circle c.
c.move(dx, dy) Moves circle c by (dx, dy)
Time(hh,mm,ss)
Creates an time object with time HH:mm:ss
t.get_XX()
Returns the secs, mins, hrs value of t, where “XX” is seconds, minutes, hours respectively.
t.add_seconds(ss)
Changes t to move by ss seconds.
t.seconds_from(T) Computes number of seconds between t and T. Returns the computation.
cwin.clear()
Clears the window
cwin.coord(x,y,u,v)
Sets the coordinate system of the graphics window with the top left point (x, y) and
the bottom right point (u,v).
cwin.get_int(s)
Prompts the user with string s for an integer. Returns the input integer.
cwin.get_string(s)
Prompts the user with string s for a string. Returns the input string.
cwin.get_double(s)
Prompts the user with string s for a double. Returns the input double.
cwin.get_mouse(s)
Prompts the user with string s for a mouse click. Returns a Point object with the
coordinates of the mouse click on the graphics window.
Basic skeleton code for your programs
Console (Terminal) program skeleton code
Compile with: g++ main.cpp
Graphics program skeleton code
Compile with: compile
#include <iostream>
#include “ccc_win.h”
#include “ccc_time.h”
using namespace std;
/* Your function declarations go here */
/* Your function declarations go here */
int main()
{
int ccc_win_main()
{
/*
* All your main code goes here
*/
/*
* All your main code goes here
*/
return 0;
return 0;
}
}
/* Your function definitions go here */
/* Your function definitions go here */
Download