Jameo Core Library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
jm::Rect Struct Reference

Defines a rectangle. More...

Public Member Functions

 Rect ()
 Constructor creates rectangle <0,0,0,0>
 
 Rect (double rx, double ry, double rwidth, double rheight)
 Constructor creates rectangle <rx,ry,rwidth,rheight.
 
 Rect (Point origin, Size size)
 
 Rect (double x, double y, const Size &size)
 
double x () const
 X-Component of top left corner.
 
double y () const
 Y-Component of top left corner.
 
double width () const
 Width of the rectangle (along x-axis)
 
double height () const
 Height of the rectangle (along y-axis)
 
Size size () const
 Returns the size of the rectangle.
 
Point origin () const
 Returns the position of the rectangle, which is the bottom left corner.
 
double left () const
 Returns the x-coordinate of the left edge of the rectangle.
 
double right () const
 Returns the x-coordinate of the right edge of the rectangle.
 
double top () const
 Returns the y-coordinate of the top edge of the rectangle.
 
double bottom () const
 Returns the y-coordinate of the bottom edge of the rectangle.
 
Point center () const
 Returns the center point of the rectangle.
 
Point topLeft () const
 Returns the top-left point.
 
Point topRight () const
 Returns the top-right point.
 
Point bottomLeft () const
 Returns the bottom-left point.
 
Point bottomRight () const
 Returns the bottom-left point.
 
Point topCenter () const
 
Point bottomCenter () const
 
Point leftCenter () const
 
Point rightCenter () const
 
void setX (double x)
 
void setY (double y)
 
void setWidth (double width)
 
void setHeight (double height)
 
void setSize (const Size &sz)
 Set the size of the rectangle.
 
void setSize (double width, double height)
 Set the size of the rectangle.
 
void setOrigin (const Point &pt)
 Set the position of the rectangle.
 
void setOrigin (double x, double y)
 
void moveLeft (double delta)
 
void moveRight (double delta)
 
void moveBottom (double delta)
 
void setTop (double top)
 Set the top edge absolutely (and change size of rectanlge)
 
void setBottom (double bottom)
 Move the bottom edge absolutely (and change size of rectanlge)
 
void setLeft (double left)
 Move the left edge absolutely (and change size of rectanlge)
 
void setRight (double right)
 Move the right edge absolutely (and change size of rectanlge)
 
void moveHorizontal (double deltaX)
 Moves the rectangle horizontally.
 
void moveVertical (double deltaY)
 Moves the rectangle vertically.
 
void move (const jm::Point &delta)
 Moves the rectangle.
 
void alignTopLeft (const Rect &rect)
 The top-left corner of this and the other Rect are aligned.
 
void alignBottomLeft (const Rect &rect)
 The bottom-left corner of this and the other Rect are aligned.
 
void shiftTop (double deltaTop)
 Move the top edge relatively (and resize)
 
void shiftLeft (double deltaLeft)
 Move the left edge relatively (and resize)
 
void shiftRight (double deltaRight)
 Move the right edge relatively (and resize)
 
void shiftBottom (double deltaBottom)
 Move the bottom edge relatively (and resize)
 
void unionWith (const Rect &rect)
 Enlarges this rectangle to a common rectangle with the other.
 
void normalize ()
 Normalized the rectangle.
 
bool isEmpty () const
 Is the rectangle empty? (Size == 0)
 
void intersect (const Rect &other)
 Change this rect to the intersection area of this rectangle with the other rect.
 
Rect intersection (const Rect &rect) const
 Returns the rectangle that is the intersection of both rectangles.
 
bool contains (double px, double py) const
 Returns true, if the point <px,py> is within this rectangle. False otherwise.
 
bool contains (const Point &pt) const
 Returns true, if the point pt is within this rectangle. False otherwise.
 
bool contains (const Vertex2 &pt) const
 Returns true, if the point pt is within this rectangle. False otherwise.
 
bool intersects (const Rect &rect) const
 Returns true, if the rectangle rect intersects this rectangle. False otherwise.
 

Detailed Description

Defines a rectangle.

Constructor & Destructor Documentation

◆ Rect() [1/4]

jm::Rect::Rect ( )

Constructor creates rectangle <0,0,0,0>

◆ Rect() [2/4]

jm::Rect::Rect ( double  rx,
double  ry,
double  rwidth,
double  rheight 
)

Constructor creates rectangle <rx,ry,rwidth,rheight.

Parameters
rxX-Component of the top left corner of the rect.
ryY-Component of the top left corner of the rect.
rwidthWidth of the rectangle (which is parallel to X-Axis)
rheightHeight of the rectangle (which is parallel to Y-Axis)

◆ Rect() [3/4]

jm::Rect::Rect ( Point  origin,
Size  size 
)

◆ Rect() [4/4]

jm::Rect::Rect ( double  x,
double  y,
const Size size 
)

Member Function Documentation

◆ alignBottomLeft()

void jm::Rect::alignBottomLeft ( const Rect rect)

The bottom-left corner of this and the other Rect are aligned.

◆ alignTopLeft()

void jm::Rect::alignTopLeft ( const Rect rect)

The top-left corner of this and the other Rect are aligned.

◆ bottom()

double jm::Rect::bottom ( ) const

Returns the y-coordinate of the bottom edge of the rectangle.

◆ bottomCenter()

Point jm::Rect::bottomCenter ( ) const

◆ bottomLeft()

Point jm::Rect::bottomLeft ( ) const

Returns the bottom-left point.

◆ bottomRight()

Point jm::Rect::bottomRight ( ) const

Returns the bottom-left point.

◆ center()

Point jm::Rect::center ( ) const

Returns the center point of the rectangle.

◆ contains() [1/3]

bool jm::Rect::contains ( const Point pt) const

Returns true, if the point pt is within this rectangle. False otherwise.

Parameters
ptThe point.

◆ contains() [2/3]

bool jm::Rect::contains ( const Vertex2 pt) const

Returns true, if the point pt is within this rectangle. False otherwise.

Parameters
ptThe point.

◆ contains() [3/3]

bool jm::Rect::contains ( double  px,
double  py 
) const

Returns true, if the point <px,py> is within this rectangle. False otherwise.

Parameters
pxX-Component of the point.
pyY-Component of the point.

◆ height()

double jm::Rect::height ( ) const

Height of the rectangle (along y-axis)

◆ intersect()

void jm::Rect::intersect ( const Rect other)

Change this rect to the intersection area of this rectangle with the other rect.

◆ intersection()

Rect jm::Rect::intersection ( const Rect rect) const

Returns the rectangle that is the intersection of both rectangles.

◆ intersects()

bool jm::Rect::intersects ( const Rect rect) const

Returns true, if the rectangle rect intersects this rectangle. False otherwise.

Parameters
rectThe rectangle

◆ isEmpty()

bool jm::Rect::isEmpty ( ) const

Is the rectangle empty? (Size == 0)

◆ left()

double jm::Rect::left ( ) const

Returns the x-coordinate of the left edge of the rectangle.

◆ leftCenter()

Point jm::Rect::leftCenter ( ) const

◆ move()

void jm::Rect::move ( const jm::Point delta)

Moves the rectangle.

◆ moveBottom()

void jm::Rect::moveBottom ( double  delta)

◆ moveHorizontal()

void jm::Rect::moveHorizontal ( double  deltaX)

Moves the rectangle horizontally.

◆ moveLeft()

void jm::Rect::moveLeft ( double  delta)

◆ moveRight()

void jm::Rect::moveRight ( double  delta)

◆ moveVertical()

void jm::Rect::moveVertical ( double  deltaY)

Moves the rectangle vertically.

◆ normalize()

void jm::Rect::normalize ( )

Normalized the rectangle.

Normalizing means, that a rectangle with negative width or height value becomes positive with and height values and the position is corrected in that way, that the outline of the rect remains on the same position and size.

◆ origin()

Point jm::Rect::origin ( ) const

Returns the position of the rectangle, which is the bottom left corner.

◆ right()

double jm::Rect::right ( ) const

Returns the x-coordinate of the right edge of the rectangle.

◆ rightCenter()

Point jm::Rect::rightCenter ( ) const

◆ setBottom()

void jm::Rect::setBottom ( double  bottom)

Move the bottom edge absolutely (and change size of rectanlge)

◆ setHeight()

void jm::Rect::setHeight ( double  height)

◆ setLeft()

void jm::Rect::setLeft ( double  left)

Move the left edge absolutely (and change size of rectanlge)

◆ setOrigin() [1/2]

void jm::Rect::setOrigin ( const Point pt)

Set the position of the rectangle.

Parameters
ptThe new position of the bottom left corner.

◆ setOrigin() [2/2]

void jm::Rect::setOrigin ( double  x,
double  y 
)

◆ setRight()

void jm::Rect::setRight ( double  right)

Move the right edge absolutely (and change size of rectanlge)

◆ setSize() [1/2]

void jm::Rect::setSize ( const Size sz)

Set the size of the rectangle.

Parameters
szThe new size.

◆ setSize() [2/2]

void jm::Rect::setSize ( double  width,
double  height 
)

Set the size of the rectangle.

Parameters
widthThe new width of the rectangle.
heightThe new height of the rectangle.

◆ setTop()

void jm::Rect::setTop ( double  top)

Set the top edge absolutely (and change size of rectanlge)

◆ setWidth()

void jm::Rect::setWidth ( double  width)

◆ setX()

void jm::Rect::setX ( double  x)

◆ setY()

void jm::Rect::setY ( double  y)

◆ shiftBottom()

void jm::Rect::shiftBottom ( double  deltaBottom)

Move the bottom edge relatively (and resize)

◆ shiftLeft()

void jm::Rect::shiftLeft ( double  deltaLeft)

Move the left edge relatively (and resize)

◆ shiftRight()

void jm::Rect::shiftRight ( double  deltaRight)

Move the right edge relatively (and resize)

◆ shiftTop()

void jm::Rect::shiftTop ( double  deltaTop)

Move the top edge relatively (and resize)

◆ size()

Size jm::Rect::size ( ) const

Returns the size of the rectangle.

◆ top()

double jm::Rect::top ( ) const

Returns the y-coordinate of the top edge of the rectangle.

◆ topCenter()

Point jm::Rect::topCenter ( ) const

◆ topLeft()

Point jm::Rect::topLeft ( ) const

Returns the top-left point.

◆ topRight()

Point jm::Rect::topRight ( ) const

Returns the top-right point.

◆ unionWith()

void jm::Rect::unionWith ( const Rect rect)

Enlarges this rectangle to a common rectangle with the other.

◆ width()

double jm::Rect::width ( ) const

Width of the rectangle (along x-axis)

◆ x()

double jm::Rect::x ( ) const

X-Component of top left corner.

◆ y()

double jm::Rect::y ( ) const

Y-Component of top left corner.