`class 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 | |

x0, y0, x1, y1) | Constructs a line segment from its endpoints. |

Methods | |

Returns the point at which the line ends. | |

Returns the point at which the line starts. | |

x, y) | Sets the end point in the line to (`x` , `y` ), leaving the start point unchanged. |

x, y) | Sets the initial point in the line to (`x` , `y` ), leaving the end point unchanged. |

GLine(double x0, double y0, double x1, double y1);

Constructs a line segment from its endpoints. The point
(

`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);

Sets the initial point in the line to (

`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;

Returns the point at which the line starts.

Usage:

GPoint pt = line->getStartPoint();

void setEndPoint(double x, double y);

Sets the end point in the line to (

`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;

Returns the point at which the line ends.

Usage:

GPoint pt = line->getEndPoint();