# LibBoard::Line Struct Reference

A line between two points. More...

`#include <Shapes.h>`

Inheritance diagram for LibBoard::Line:

List of all members.

## Public Member Functions

| Line (double x1, double y1, double x2, double y2, Color color, double lineWidth, const LineStyle style=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depth=-1)
const std::string & | name () const
Point | center () const
Line & | rotate (double angle, const Point &center)
Line | rotated (double angle, const Point &center) const
Line & | rotate (double angle)
Line | rotated (double angle) const
Line & | translate (double dx, double dy)
Line | translated (double dx, double dy) const
Shape & | scale (double sx, double sy)
Shape & | scale (double s)
Line | scaled (double sx, double sy) const
Line | scaled (double s) const
void | scaleAll (double s)
void | flushPostscript (std::ostream &stream, const TransformEPS &transform) const
void | flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const
void | flushSVG (std::ostream &stream, const TransformSVG &transform) const
Rect | boundingBox () const
Line * | clone () const

## Protected Attributes

double | _x1
double | _y1
double | _x2
double | _y2

## Detailed Description

A line between two points.

The line structure.

Examples:

  examples/ellipse.cpp, examples/example4.cpp, examples/koch.cpp, examples/logo.cpp, and examples/ruler.cpp.

## Constructor & Destructor Documentation

LibBoard::Line::Line | ( | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2,
|  | Color | color,
|  | double | lineWidth,
|  | const LineStyle | style = `SolidStyle`,
|  | const LineCap | cap = `ButtCap`,
|  | const LineJoin | join = `MiterJoin`,
|  | int | depth = `-1` |
| ) |  |  | `[inline]`

Constructs a line.

Parameters:

  | x1 | First coordinate of the start point.
  | y1 | Second coordinate of the start point.
  | x2 | First coordinate of the end point.
  | y2 | Second coordinate of the end point.
  | color | The color of the line.
  | lineWidth | The line thickness.
  | depth | The depth of the line.

Referenced by clone().

## Member Function Documentation

Rect LibBoard::Line::boundingBox | ( |  | ) | const`[virtual]`

Returns the bounding box of the figure.

Returns:
  The rectangle of the bounding box.

Implements LibBoard::Shape.

References _x1, _x2, _y1, _y2, LibBoard::Rect::height, LibBoard::Rect::left, LibBoard::Rect::top, and LibBoard::Rect::width.

Point LibBoard::Line::center | ( |  | ) | const`[virtual]`

Returns the gravity center of the shape.

Returns:
  The center of the shape.

Implements LibBoard::Shape.

References _x1, _x2, _y1, and _y2.

Referenced by rotate(), LibBoard::Arrow::rotated(), rotated(), scale(), LibBoard::Arrow::scaled(), and scaled().

Line * LibBoard::Line::clone | ( |  | ) | const`[virtual]`

Return a copy of the shape.

Returns:

Implements LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

References Line().

void LibBoard::Line::flushFIG | ( | std::ostream & | stream,
|  | const TransformFIG & | transform,
|  | std::map< Color, int > & | colormap |
| ) |  |  | const`[virtual]`

Writes the FIG code of the shape in a stream according to a transform.

Parameters:

  | stream | The output stream.
  | transform | A 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

References LibBoard::Shape::_depth, LibBoard::Shape::_lineCap, LibBoard::Shape::_lineJoin, LibBoard::Shape::_lineStyle, LibBoard::Shape::_lineWidth, LibBoard::Shape::_penColor, _x1, _x2, _y1, and _y2.

void LibBoard::Line::flushPostscript | ( | std::ostream & | stream,
|  | const TransformEPS & | transform |
| ) |  |  | const`[virtual]`

Writes the EPS code of the shape in a stream according to a transform.

Parameters:

  | stream | The output stream.
  | transform | A 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

References LibBoard::Shape::_penColor, _x1, _x2, _y1, _y2, and LibBoard::Shape::postscriptProperties().

void LibBoard::Line::flushSVG | ( | std::ostream & | stream,
|  | const TransformSVG & | transform |
| ) |  |  | const`[virtual]`

Writes the SVG code of the shape in a stream according to a transform.

Parameters:

  | stream | The output stream.
  | transform | A 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

References _x1, _x2, _y1, _y2, and LibBoard::Shape::svgProperties().

const std::string & LibBoard::Line::name | ( |  | ) | const`[virtual]`

Returns the generic name of the shape (e.g., Circle, Rectangle, etc.)

Returns:

Reimplemented from LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

Line & LibBoard::Line::rotate | ( | double | angle | ) | `[virtual]`

Rotate the shape around its center.

Parameters:

  | angle | The rotation angle in radian.

Returns:
  A reference to the shape itself.

Implements LibBoard::Shape.

References center(), and rotate().

Line & LibBoard::Line::rotate | ( | double | angle,
|  | const Point & | center |
| ) |  |  | `[virtual]`

Rotate the shape around a given center of rotation.

Parameters:

  | angle | The rotation angle in radian.
  | center | The center of rotation.

Returns:
  A reference to the shape itself.

Implements LibBoard::Shape.

References _x1, _x2, _y1, _y2, and rotate().

Referenced by rotate().

Line LibBoard::Line::rotated | ( | double | angle | ) | const

Returns a copy of the line, rotated around its center.

Parameters:

  | angle | The angle of rotation.

Returns:
  A copy of the lines, rotated around its center by the given angle.

Reimplemented in LibBoard::Arrow.

References _x1, _x2, _y1, _y2, and center().

Line LibBoard::Line::rotated | ( | double | angle,
|  | const Point & | center |
| ) |  |  | const

Returns a copy of the line, rotated around a given rotation center.

Parameters:

  | angle | The rotation angle.
  | center | The center of rotation.

Returns:
  The rotated copy of the line.

Reimplemented in LibBoard::Arrow.

References _x1, _x2, _y1, and _y2.

Shape & LibBoard::Line::scale | ( | double | s | ) | `[virtual]`

Scale the shape along both axis.

Parameters:

  | s | The scale factor along both axis.

Returns:
  The shape itself.

Implements LibBoard::Shape.

References scale().

Shape & LibBoard::Line::scale | ( | double | sx,
|  | double | sy |
| ) |  |  | `[virtual]`

Scale the shape along the x an y axis.

Parameters:

  | sx | The scale factor along the x axis.
  | sy | The scale factor along the y axis.

Returns:
  The shape itself.

Implements LibBoard::Shape.

References _x1, _x2, _y1, _y2, center(), translate(), LibBoard::Point::x, and LibBoard::Point::y.

Referenced by scale().

void LibBoard::Line::scaleAll | ( | double | s | ) | `[virtual]`

Scales all the values (positions, dimensions, etc.) associated with the shape.

Parameters:

  | s | The scaling factor.

Implements LibBoard::Shape.

References _x1, _x2, _y1, and _y2.

Line LibBoard::Line::scaled | ( | double | sx,
|  | double | sy |
| ) |  |  | const

Returns a scaled copy of the line.

Parameters:

  | sx | Scale factor along the x axis.
  | sy | Scale factor along the y axis.

Returns:
  A scaled copy of the line.

Reimplemented in LibBoard::Arrow.

References _x1, _x2, _y1, _y2, center(), translate(), LibBoard::Point::x, and LibBoard::Point::y.

Line & LibBoard::Line::translate | ( | double | dx,
|  | double | dy |
| ) |  |  | `[virtual]`

Translate the shape by a given offset.

Parameters:

  | dx | The x offset.
  | dy | The y offset.

Returns:
  A reference to the shape itself.

Implements LibBoard::Shape.

Examples:
  examples/ruler.cpp.

References _x1, _x2, _y1, and _y2.

Referenced by scale(), LibBoard::Arrow::scaled(), and scaled().

Line LibBoard::Line::translated | ( | double | dx,
|  | double | dy |
| ) |  |  | const

Returns a translated copy of the line.

Parameters:

  | dx | The shift along the x axis.
  | dy | The shift along the y axis.

Returns:
  A translated copy of the line.

Reimplemented in LibBoard::Arrow.

References _x1, _x2, _y1, and _y2.

## Member Data Documentation

double LibBoard::Line::_x1 `[protected]`

First coordinate of the start point.

Referenced by boundingBox(), center(), LibBoard::Arrow::flushFIG(), flushFIG(), LibBoard::Arrow::flushPostscript(), flushPostscript(), LibBoard::Arrow::flushSVG(), flushSVG(), rotate(), LibBoard::Arrow::rotated(), rotated(), scale(), scaleAll(), LibBoard::Arrow::scaled(), scaled(), translate(), LibBoard::Arrow::translated(), and translated().

double LibBoard::Line::_x2 `[protected]`

First coordinate of the end point.

Referenced by boundingBox(), center(), LibBoard::Arrow::flushFIG(), flushFIG(), LibBoard::Arrow::flushPostscript(), flushPostscript(), LibBoard::Arrow::flushSVG(), flushSVG(), rotate(), LibBoard::Arrow::rotated(), rotated(), scale(), scaleAll(), LibBoard::Arrow::scaled(), scaled(), translate(), LibBoard::Arrow::translated(), and translated().

double LibBoard::Line::_y1 `[protected]`

Second coordinate of the start point.

Referenced by boundingBox(), center(), LibBoard::Arrow::flushFIG(), flushFIG(), LibBoard::Arrow::flushPostscript(), flushPostscript(), LibBoard::Arrow::flushSVG(), flushSVG(), rotate(), LibBoard::Arrow::rotated(), rotated(), scale(), scaleAll(), LibBoard::Arrow::scaled(), scaled(), translate(), LibBoard::Arrow::translated(), and translated().

double LibBoard::Line::_y2 `[protected]`

Second coordinate of the end point.

Referenced by boundingBox(), center(), LibBoard::Arrow::flushFIG(), flushFIG(), LibBoard::Arrow::flushPostscript(), flushPostscript(), LibBoard::Arrow::flushSVG(), flushSVG(), rotate(), LibBoard::Arrow::rotated(), rotated(), scale(), scaleAll(), LibBoard::Arrow::scaled(), scaled(), translate(), LibBoard::Arrow::translated(), and translated().

The documentation for this struct was generated from the following files:

- include/board/Shapes.h
- src/Shapes.cpp