Board 0.9.6
Public Member Functions | Public Attributes | List of all members
LibBoard::Rect Struct Reference

Struct representing a rectangle on the plane. More...

#include <Rect.h>

Public Member Functions

 Rect (double left=0.0, double top=0.0, double width=0.0, double height=0.0)
 
 Rect (Point topLeft, double width=0.0, double height=0.0)
 
 Rect (Point topLeft, Point bottomRight)
 
Point topLeft () const
 topLeft Top-left point of the rectangle
 
Point topRight () const
 topRight Top-right point of the rectangle
 
Point bottomLeft () const
 bottomLeft Bottom-left point of the rectangle
 
Point bottomRight () const
 bottomRight Bottom-right point of the rectangle
 
Point center () const
 center The center of the rectangle
 
Point centerLeft () const
 centerLeft The center of the left border of the rectangle
 
Point centerRight () const
 centerRight The center of the right border of the rectangle
 
Point centerTop () const
 centerTop The center of the top border of the rectangle
 
Point centerBottom () const
 centerBottom The center of the bottom border of the rectangle
 
double bottom () const
 The y coordinate of the bottom of the rectangle.
 
double right () const
 The x coordinate of the right side of the rectangle.
 
double diameter () const
 diameter
 
void clear ()
 Set to a rectangle with zero width and height at position (0,0)
 
RectgrowToContain (const Point &p)
 Grow the rectangle so that it contains the point p.
 
RectgrowToContain (const std::vector< Point > &points)
 Grow the rectangle so that it contains a set of points.
 
bool contains (Point p) const
 Check whether or not a point is contained in the rectangle (including its border)
 
bool strictlyContains (Point p) const
 Check whether or not a point is strictly contained in the rectangle.
 
bool intersects (const Rect &other) const
 Check whether the rectangle intersects another rectangle.
 
bool strictlyIntersects (const Rect &other) const
 Check whether the rectangle strictly intersects another rectangle.
 
Rectgrow (double margin)
 Grow the rectangle by a given distance (margin) in each direction.
 
Rect growed (double margin)
 Return the rectangle growed by a given distance (margin) in each direction.
 
bool isNull () const
 Check if a rectangle is null (i.e., zero sized)
 

Public Attributes

double left
 
double top
 
double width
 
double height
 

Detailed Description

Struct representing a rectangle on the plane.

The Rectangle structure.

Examples
examples/Huffman.cpp, examples/arrows.cpp, examples/ellipse.cpp, examples/tilings.cpp, and examples/traversal.cpp.

Constructor & Destructor Documentation

◆ Rect() [1/3]

LibBoard::Rect::Rect ( double  left = 0.0,
double  top = 0.0,
double  width = 0.0,
double  height = 0.0 
)
inline

Rect constructor

Parameters
leftx coordinate of the left border of the rectangle
topy coordinate of the top border of the rectangle
widthwidth of the rectangle
heightheight of the rectangle

◆ Rect() [2/3]

LibBoard::Rect::Rect ( Point  topLeft,
double  width = 0.0,
double  height = 0.0 
)
inline

Rect constructor.

Parameters
topLeftThe top-left point of the rectangle
widthWidth of the rectangle
heightHeight of the rectangle

◆ Rect() [3/3]

LibBoard::Rect::Rect ( Point  topLeft,
Point  bottomRight 
)
inline

Rect constructor.

Parameters
topLeftThe top-left point of the rectangle.
bottomRightThe bottom-right point of the rectangle.

Member Function Documentation

◆ bottom()

double LibBoard::Rect::bottom ( ) const
inline

The y coordinate of the bottom of the rectangle.

Returns
The y coordinate of the bottom of the rectangle

References height, and top.

Referenced by LibBoard::ShapeList::append(), LibBoard::boardFontText(), LibBoard::hachures(), and LibBoard::Board::saveEPS().

◆ bottomLeft()

Point LibBoard::Rect::bottomLeft ( ) const
inline

bottomLeft Bottom-left point of the rectangle

Returns
The point at the bottom-left corner of the rectangle
Examples
examples/sandbox.cpp, and examples/tilings.cpp.

References height, left, and top.

Referenced by intersects(), main(), and strictlyIntersects().

◆ bottomRight()

Point LibBoard::Rect::bottomRight ( ) const
inline

bottomRight Bottom-right point of the rectangle

Returns
The point at the bottom-right corner of the rectangle
Examples
examples/arrows.cpp, and examples/tilings.cpp.

References height, left, top, and width.

Referenced by intersects(), main(), and strictlyIntersects().

◆ center()

Point LibBoard::Rect::center ( ) const
inline

◆ centerBottom()

Point LibBoard::Rect::centerBottom ( ) const
inline

centerBottom The center of the bottom border of the rectangle

Returns
The point at the center of the bottom border of the rectangle

References height, left, top, and width.

◆ centerLeft()

Point LibBoard::Rect::centerLeft ( ) const
inline

centerLeft The center of the left border of the rectangle

Returns
The point at the center of the left border of the rectangle

References height, left, and top.

◆ centerRight()

Point LibBoard::Rect::centerRight ( ) const
inline

centerRight The center of the right border of the rectangle

Returns
The point at the center of the right border of the rectangle

References height, left, top, and width.

◆ centerTop()

Point LibBoard::Rect::centerTop ( ) const
inline

centerTop The center of the top border of the rectangle

Returns
The point at the center of the top border of the rectangle

References left, top, and width.

◆ clear()

void LibBoard::Rect::clear ( )
inline

Set to a rectangle with zero width and height at position (0,0)

References height, left, top, and width.

Referenced by LibBoard::Tools::getEPSBoundingBox().

◆ contains()

bool LibBoard::Rect::contains ( Point  p) const

Check whether or not a point is contained in the rectangle (including its border)

Parameters
pA point
Returns
true if the point is in the rectangle, otherwise false

References height, left, top, width, LibBoard::Point::x, and LibBoard::Point::y.

Referenced by intersects().

◆ diameter()

double LibBoard::Rect::diameter ( ) const
inline

diameter

Returns
The distance between two opposite corners

References height, and width.

Referenced by LibBoard::circled().

◆ grow()

Rect & LibBoard::Rect::grow ( double  margin)

Grow the rectangle by a given distance (margin) in each direction.

Parameters
marginThe margin to be added
Returns
A reference to the rectangle itself

References height, left, top, and width.

Referenced by LibBoard::Ellipse::boundingBox(), LibBoard::framed(), growed(), and main().

◆ growed()

Rect LibBoard::Rect::growed ( double  margin)

Return the rectangle growed by a given distance (margin) in each direction.

Parameters
marginThe margin to be added
Returns
A new rectangle, result of the growth
Examples
examples/Huffman.cpp.

References grow().

Referenced by merge().

◆ growToContain() [1/2]

Rect & LibBoard::Rect::growToContain ( const Point p)

Grow the rectangle so that it contains the point p.

Parameters
pA point
Returns
A reference to the rectangle itself

References height, left, top, width, LibBoard::Point::x, and LibBoard::Point::y.

Referenced by LibBoard::Path::boundingBox(), growToContain(), and LibBoard::Tools::pathBoundingBox().

◆ growToContain() [2/2]

Rect & LibBoard::Rect::growToContain ( const std::vector< Point > &  points)

Grow the rectangle so that it contains a set of points.

Parameters
pointsA set of points
Returns
A reference to the rectangle itself

References growToContain(), and point().

◆ intersects()

bool LibBoard::Rect::intersects ( const Rect other) const

Check whether the rectangle intersects another rectangle.

Parameters
otherAnother rectangle
Returns
true if the rectangles intersect, otherwise false

References bottomLeft(), bottomRight(), contains(), topLeft(), and topRight().

◆ isNull()

bool LibBoard::Rect::isNull ( ) const
inline

Check if a rectangle is null (i.e., zero sized)

Returns
true if the rectangle is null, otherwise false

References height, and width.

Referenced by LibBoard::operator||().

◆ right()

double LibBoard::Rect::right ( ) const
inline

The x coordinate of the right side of the rectangle.

Returns
The x coordinate of the right side of the rectangle

References left, and width.

Referenced by LibBoard::ShapeList::append(), and LibBoard::Board::saveEPS().

◆ strictlyContains()

bool LibBoard::Rect::strictlyContains ( Point  p) const

Check whether or not a point is strictly contained in the rectangle.

Parameters
pA point
Returns
true if the point is inside the rectangle, otherwise false

References height, left, top, width, LibBoard::Point::x, and LibBoard::Point::y.

Referenced by strictlyIntersects().

◆ strictlyIntersects()

bool LibBoard::Rect::strictlyIntersects ( const Rect other) const

Check whether the rectangle strictly intersects another rectangle.

Parameters
otherAnother rectangle
Returns
true if the rectangles strictly intersect, otherwise false

References bottomLeft(), bottomRight(), strictlyContains(), topLeft(), and topRight().

◆ topLeft()

Point LibBoard::Rect::topLeft ( ) const
inline

topLeft Top-left point of the rectangle

Returns
The point at the top-left corner of the rectangle
Examples
examples/arrows.cpp.

References left, and top.

Referenced by intersects(), main(), and strictlyIntersects().

◆ topRight()

Point LibBoard::Rect::topRight ( ) const
inline

topRight Top-right point of the rectangle

Returns
The point at the top-right corner of the rectangle
Examples
examples/circled_framed.cpp, examples/example1.cpp, examples/ruler.cpp, examples/tilings.cpp, and examples/xkcd.cpp.

References left, top, and width.

Referenced by intersects(), main(), and strictlyIntersects().

Member Data Documentation

◆ height

double LibBoard::Rect::height

◆ left

double LibBoard::Rect::left

◆ top

double LibBoard::Rect::top

◆ width

double LibBoard::Rect::width

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