SimpleCxxLib
packageclass GLine : public GObject
int main() { GWindow gw; cout << "This program draws the diagonals on the window." << endl; gw.add(new GLine(0, 0, gw.getWidth(), gw.getHeight())); gw.add(new GLine(0, gw.getHeight(), gw.getWidth(), 0)); return 0; }
Constructor | |
Constructs a line segment from its endpoints. | |
Methods | |
Returns the point at which the line ends. | |
Returns the point at which the line starts. | |
Sets the end point in the line to (x , y ), leaving the start point unchanged. | |
Sets the initial point in the line to (x , y ), leaving the end point unchanged. |
GLine(double x0, double y0, double x1, double y1);
x0
, y0
) defines the start of the
line and the point (x1
, y1
) defines
the end.
Usage:
GLine *gline = new GLine(x0, y0, x1, y1);
void setStartPoint(double x, double y);
x
, y
),
leaving the end point unchanged. This method is therefore different from
setLocation
, which moves both components of the line segment.
Usage:
line->setStartPoint(x, y);
GPoint getStartPoint() const;
Usage:
GPoint pt = line->getStartPoint();
void setEndPoint(double x, double y);
x
, y
),
leaving the start point unchanged. This method is therefore different from
setLocation
, which moves both components of the line segment.
Usage:
line->setEndPoint(x, y);
GPoint getEndPoint() const;
Usage:
GPoint pt = line->getEndPoint();