Loading...
Searching...
No Matches
juce::Rectangle< ValueType > Class Template Reference

## Detailed Description

template<typename ValueType>
class juce::Rectangle< ValueType >

Manages a rectangle and allows geometric operations to be performed on it.

See also
  RectangleList, Path, Line, Point

The documentation for this class was generated from the following file:

- juce_graphics/geometry/juce_Rectangle.h

## Public Member Functions

| Rectangle ()=default
| Creates a rectangle of zero size.
| Rectangle (const Rectangle &)=default
| Creates a copy of another rectangle.
| Rectangle (ValueType initialX, ValueType initialY, ValueType width, ValueType height) noexcept
| Creates a rectangle with a given position and size.
| Rectangle (ValueType width, ValueType height) noexcept
| Creates a rectangle with a given size, and a position of (0, 0).
| Rectangle (Point< ValueType > corner1, Point< ValueType > corner2) noexcept
| Creates a Rectangle from the positions of two opposite corners.
Rectangle & | operator= (const Rectangle &)=default
| Creates a copy of another rectangle.
| ~Rectangle ()=default
| Destructor.
bool | isEmpty () const noexcept
| Returns true if the rectangle's width or height are zero or less.
bool | isFinite () const noexcept
| Returns true if the rectangle's values are all finite numbers, i.e.
ValueType | getX () const noexcept
| Returns the x coordinate of the rectangle's left-hand-side.
ValueType | getY () const noexcept
| Returns the y coordinate of the rectangle's top edge.
ValueType | getWidth () const noexcept
| Returns the width of the rectangle.
ValueType | getHeight () const noexcept
| Returns the height of the rectangle.
ValueType | getRight () const noexcept
| Returns the x coordinate of the rectangle's right-hand-side.
ValueType | getBottom () const noexcept
| Returns the y coordinate of the rectangle's bottom edge.
ValueType | getCentreX () const noexcept
| Returns the x coordinate of the rectangle's centre.
ValueType | getCentreY () const noexcept
| Returns the y coordinate of the rectangle's centre.
Point< ValueType > | getCentre () const noexcept
| Returns the centre point of the rectangle.
ValueType | getAspectRatio (bool widthOverHeight=true) const noexcept
| Returns the aspect ratio of the rectangle's width / height.
Point< ValueType > | getPosition () const noexcept
| Returns the rectangle's top-left position as a Point.
void | setPosition (Point< ValueType > newPos) noexcept
| Changes the position of the rectangle's top-left corner (leaving its size unchanged).
void | setPosition (ValueType newX, ValueType newY) noexcept
| Changes the position of the rectangle's top-left corner (leaving its size unchanged).
Point< ValueType > | getTopLeft () const noexcept
| Returns the rectangle's top-left position as a Point.
Point< ValueType > | getTopRight () const noexcept
| Returns the rectangle's top-right position as a Point.
Point< ValueType > | getBottomLeft () const noexcept
| Returns the rectangle's bottom-left position as a Point.
Point< ValueType > | getBottomRight () const noexcept
| Returns the rectangle's bottom-right position as a Point.
Range< ValueType > | getHorizontalRange () const noexcept
| Returns the rectangle's left and right positions as a Range.
Range< ValueType > | getVerticalRange () const noexcept
| Returns the rectangle's top and bottom positions as a Range.
void | setSize (ValueType newWidth, ValueType newHeight) noexcept
| Changes the rectangle's size, leaving the position of its top-left corner unchanged.
void | setBounds (ValueType newX, ValueType newY, ValueType newWidth, ValueType newHeight) noexcept
| Changes all the rectangle's coordinates.
void | setX (ValueType newX) noexcept
| Changes the rectangle's X coordinate.
void | setY (ValueType newY) noexcept
| Changes the rectangle's Y coordinate.
void | setWidth (ValueType newWidth) noexcept
| Changes the rectangle's width.
void | setHeight (ValueType newHeight) noexcept
| Changes the rectangle's height.
void | setCentre (ValueType newCentreX, ValueType newCentreY) noexcept
| Changes the position of the rectangle's centre (leaving its size unchanged).
void | setCentre (Point< ValueType > newCentre) noexcept
| Changes the position of the rectangle's centre (leaving its size unchanged).
void | setHorizontalRange (Range< ValueType > range) noexcept
| Changes the position of the rectangle's left and right edges.
void | setVerticalRange (Range< ValueType > range) noexcept
| Changes the position of the rectangle's top and bottom edges.
Rectangle | withX (ValueType newX) const noexcept
| Returns a rectangle which has the same size and y-position as this one, but with a different x-position.
Rectangle | withY (ValueType newY) const noexcept
| Returns a rectangle which has the same size and x-position as this one, but with a different y-position.
Rectangle | withRightX (ValueType newRightX) const noexcept
| Returns a rectangle which has the same size and y-position as this one, but whose right-hand edge has the given position.
Rectangle | withBottomY (ValueType newBottomY) const noexcept
| Returns a rectangle which has the same size and x-position as this one, but whose bottom edge has the given position.
Rectangle | withPosition (ValueType newX, ValueType newY) const noexcept
| Returns a rectangle with the same size as this one, but a new position.
Rectangle | withPosition (Point< ValueType > newPos) const noexcept
| Returns a rectangle with the same size as this one, but a new position.
Rectangle | withZeroOrigin () const noexcept
| Returns a rectangle whose size is the same as this one, but whose top-left position is (0, 0).
Rectangle | withCentre (Point< ValueType > newCentre) const noexcept
| Returns a rectangle with the same size as this one, but a new centre position.
Rectangle | withWidth (ValueType newWidth) const noexcept
| Returns a rectangle which has the same position and height as this one, but with a different width.
Rectangle | withHeight (ValueType newHeight) const noexcept
| Returns a rectangle which has the same position and width as this one, but with a different height.
Rectangle | withSize (ValueType newWidth, ValueType newHeight) const noexcept
| Returns a rectangle with the same top-left position as this one, but a new size.
Rectangle | withSizeKeepingCentre (ValueType newWidth, ValueType newHeight) const noexcept
| Returns a rectangle with the same centre position as this one, but a new size.
void | setLeft (ValueType newLeft) noexcept
| Moves the x position, adjusting the width so that the right-hand edge remains in the same place.
Rectangle | withLeft (ValueType newLeft) const noexcept
| Returns a new rectangle with a different x position, but the same right-hand edge as this one.
void | setTop (ValueType newTop) noexcept
| Moves the y position, adjusting the height so that the bottom edge remains in the same place.
Rectangle | withTop (ValueType newTop) const noexcept
| Returns a new rectangle with a different y position, but the same bottom edge as this one.
void | setRight (ValueType newRight) noexcept
| Adjusts the width so that the right-hand edge of the rectangle has this new value.
Rectangle | withRight (ValueType newRight) const noexcept
| Returns a new rectangle with a different right-hand edge position, but the same left-hand edge as this one.
void | setBottom (ValueType newBottom) noexcept
| Adjusts the height so that the bottom edge of the rectangle has this new value.
Rectangle | withBottom (ValueType newBottom) const noexcept
| Returns a new rectangle with a different bottom edge position, but the same top edge as this one.
Rectangle | withTrimmedLeft (ValueType amountToRemove) const noexcept
| Returns a version of this rectangle with the given amount removed from its left-hand edge.
Rectangle | withTrimmedRight (ValueType amountToRemove) const noexcept
| Returns a version of this rectangle with the given amount removed from its right-hand edge.
Rectangle | withTrimmedTop (ValueType amountToRemove) const noexcept
| Returns a version of this rectangle with the given amount removed from its top edge.
Rectangle | withTrimmedBottom (ValueType amountToRemove) const noexcept
| Returns a version of this rectangle with the given amount removed from its bottom edge.
void | translate (ValueType deltaX, ValueType deltaY) noexcept
| Moves the rectangle's position by adding amount to its x and y coordinates.
Rectangle | translated (ValueType deltaX, ValueType deltaY) const noexcept
| Returns a rectangle which is the same as this one moved by a given amount.
Rectangle | operator+ (Point< ValueType > deltaPosition) const noexcept
| Returns a rectangle which is the same as this one moved by a given amount.
Rectangle & | operator+= (Point< ValueType > deltaPosition) noexcept
| Moves this rectangle by a given amount.
Rectangle | operator- (Point< ValueType > deltaPosition) const noexcept
| Returns a rectangle which is the same as this one moved by a given amount.
Rectangle & | operator-= (Point< ValueType > deltaPosition) noexcept
| Moves this rectangle by a given amount.
template<typename FloatType>
Rectangle | operator* (FloatType scaleFactor) const noexcept
| Returns a rectangle that has been scaled by the given amount, centred around the origin.
template<typename FloatType>
Rectangle | operator*= (FloatType scaleFactor) noexcept
| Scales this rectangle by the given amount, centred around the origin.
template<typename FloatType>
Rectangle | operator*= (Point< FloatType > scaleFactor) noexcept
| Scales this rectangle by the given X and Y factors, centred around the origin.
template<typename FloatType>
Rectangle | operator/ (FloatType scaleFactor) const noexcept
| Scales this rectangle by the given amount, centred around the origin.
template<typename FloatType>
Rectangle | operator/= (FloatType scaleFactor) noexcept
| Scales this rectangle by the given amount, centred around the origin.
template<typename FloatType>
Rectangle | operator/= (Point< FloatType > scaleFactor) noexcept
| Scales this rectangle by the given X and Y factors, centred around the origin.
void | expand (ValueType deltaX, ValueType deltaY) noexcept
| Expands the rectangle by a given amount.
Rectangle | expanded (ValueType deltaX, ValueType deltaY) const noexcept
| Returns a rectangle that is larger than this one by a given amount.
Rectangle | expanded (ValueType delta) const noexcept
| Returns a rectangle that is larger than this one by a given amount.
void | reduce (ValueType deltaX, ValueType deltaY) noexcept
| Shrinks the rectangle by a given amount.
Rectangle | reduced (ValueType deltaX, ValueType deltaY) const noexcept
| Returns a rectangle that is smaller than this one by a given amount.
Rectangle | reduced (ValueType delta) const noexcept
| Returns a rectangle that is smaller than this one by a given amount.
Rectangle | removeFromTop (ValueType amountToRemove) noexcept
| Removes a strip from the top of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.
Rectangle | removeFromLeft (ValueType amountToRemove) noexcept
| Removes a strip from the left-hand edge of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.
Rectangle | removeFromRight (ValueType amountToRemove) noexcept
| Removes a strip from the right-hand edge of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.
Rectangle | removeFromBottom (ValueType amountToRemove) noexcept
| Removes a strip from the bottom of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.
Point< ValueType > | getConstrainedPoint (Point< ValueType > point) const noexcept
| Returns the nearest point to the specified point that lies within this rectangle.
template<typename FloatType>
Point< ValueType > | getRelativePoint (FloatType relativeX, FloatType relativeY) const noexcept
| Returns a point within this rectangle, specified as proportional coordinates.
template<typename FloatType>
ValueType | proportionOfWidth (FloatType proportion) const noexcept
| Returns a proportion of the width of this rectangle.
template<typename FloatType>
ValueType | proportionOfHeight (FloatType proportion) const noexcept
| Returns a proportion of the height of this rectangle.
template<typename FloatType>
Rectangle | getProportion (Rectangle< FloatType > proportionalRect) const noexcept
| Returns a rectangle based on some proportional coordinates relative to this one.
bool | operator== (const Rectangle &other) const noexcept
| Returns true if the two rectangles are identical.
bool | operator!= (const Rectangle &other) const noexcept
| Returns true if the two rectangles are not identical.
bool | contains (ValueType xCoord, ValueType yCoord) const noexcept
| Returns true if this coordinate is inside the rectangle.
bool | contains (Point< ValueType > point) const noexcept
| Returns true if this coordinate is inside the rectangle.
bool | contains (Rectangle other) const noexcept
| Returns true if this other rectangle is completely inside this one.
bool | intersects (Rectangle other) const noexcept
| Returns true if any part of another rectangle overlaps this one.
bool | intersects (const Line< ValueType > &line) const noexcept
| Returns true if any part of the given line lies inside this rectangle.
Rectangle | getIntersection (Rectangle other) const noexcept
| Returns the region that is the overlap between this and another rectangle.
bool | intersectRectangle (ValueType &otherX, ValueType &otherY, ValueType &otherW, ValueType &otherH) const noexcept
| Clips a set of rectangle coordinates so that they lie only within this one.
bool | intersectRectangle (Rectangle< ValueType > &rectangleToClip) const noexcept
| Clips a rectangle so that it lies only within this one.
Rectangle | getUnion (Rectangle other) const noexcept
| Returns the smallest rectangle that contains both this one and the one passed-in.
bool | enlargeIfAdjacent (Rectangle other) noexcept
| If this rectangle merged with another one results in a simple rectangle, this will set this rectangle to the result, and return true.
bool | reduceIfPartlyContainedIn (Rectangle other) noexcept
| If after removing another rectangle from this one the result is a simple rectangle, this will set this object's bounds to be the result, and return true.
Rectangle | constrainedWithin (Rectangle areaToFitWithin) const noexcept
| Tries to fit this rectangle within a target area, returning the result.
Rectangle | transformedBy (const AffineTransform &transform) const noexcept
| Returns the smallest rectangle that can contain the shape created by applying a transform to this rectangle.
Rectangle< int > | getSmallestIntegerContainer () const noexcept
| Returns the smallest integer-aligned rectangle that completely contains this one.
Rectangle< int > | getLargestIntegerWithin () const noexcept
| Returns the largest integer-aligned rectangle that is completely contained by this one.
Rectangle< int > | toNearestInt () const noexcept
| Casts this rectangle to a Rectangle<int>.
Rectangle< int > | toNearestIntEdges () const noexcept
| Casts this rectangle to a Rectangle<int>.
Rectangle< float > | toFloat () const noexcept
| Casts this rectangle to a Rectangle<float>.
Rectangle< double > | toDouble () const noexcept
| Casts this rectangle to a Rectangle<double>.
template<typename TargetType>
Rectangle< TargetType > | toType () const noexcept
| Casts this rectangle to a Rectangle with the given type.
String | toString () const
| Creates a string describing this rectangle.

## Static Public Member Functions

static Rectangle | leftTopRightBottom (ValueType left, ValueType top, ValueType right, ValueType bottom) noexcept
| Creates a Rectangle from a set of left, right, top, bottom coordinates.
static Rectangle | findAreaContainingPoints (const Point< ValueType > *points, int numPoints) noexcept
| Returns the smallest Rectangle that can contain a set of points.
static bool | intersectRectangles (ValueType &x1, ValueType &y1, ValueType &w1, ValueType &h1, ValueType x2, ValueType y2, ValueType w2, ValueType h2) noexcept
| Static utility to intersect two sets of rectangular coordinates.
static Rectangle | fromString (StringRef stringVersion)
| Parses a string containing a rectangle's details.

## Constructors and Destructors

## Rectangle() [1/5]

template<typename ValueType>

juce::Rectangle< ValueType >::Rectangle | ( |  | ) |

default

Creates a rectangle of zero size.

The default coordinates will be (0, 0, 0, 0).

## Rectangle() [2/5]

template<typename ValueType>

juce::Rectangle< ValueType >::Rectangle | ( | const Rectangle< ValueType > & |  | ) |

default

Creates a copy of another rectangle.

References Rectangle.

## Rectangle() [3/5]

template<typename ValueType>

juce::Rectangle< ValueType >::Rectangle | ( | ValueType | initialX,
|  | ValueType | initialY,
|  | ValueType | width,
|  | ValueType | height )

inline noexcept

Creates a rectangle with a given position and size.

## Rectangle() [4/5]

template<typename ValueType>

juce::Rectangle< ValueType >::Rectangle | ( | ValueType | width,
|  | ValueType | height )

inline noexcept

Creates a rectangle with a given size, and a position of (0, 0).

## Rectangle() [5/5]

template<typename ValueType>

juce::Rectangle< ValueType >::Rectangle | ( | Point< ValueType > | corner1,
|  | Point< ValueType > | corner2 )

inline noexcept

Creates a Rectangle from the positions of two opposite corners.

References juce::jmin().

## ~Rectangle()

template<typename ValueType>

juce::Rectangle< ValueType >::~Rectangle | ( |  | ) |

default

Destructor.

## Member Functions

## leftTopRightBottom()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::leftTopRightBottom | ( | ValueType | left,
|  | ValueType | top,
|  | ValueType | right,
|  | ValueType | bottom )

inline static noexcept

Creates a Rectangle from a set of left, right, top, bottom coordinates.

The right and bottom values must be larger than the left and top ones, or the resulting rectangle will have a negative size.

References Rectangle.

Referenced by getSmallestIntegerContainer(), and toNearestIntEdges().

## operator=()

template<typename ValueType>

Rectangle & juce::Rectangle< ValueType >::operator= | ( | const Rectangle< ValueType > & |  | ) |

default

Creates a copy of another rectangle.

References Rectangle.

## isEmpty()

template<typename ValueType>

bool juce::Rectangle< ValueType >::isEmpty | ( |  | ) | const

inline noexcept

Returns true if the rectangle's width or height are zero or less.

Referenced by juce::RectangleList< ValueType >::add(), juce::RectangleList< ValueType >::addWithoutMerging(), juce::RectangleList< ValueType >::clipTo(), juce::RectangleList< ValueType >::getIntersectionWith(), and getUnion().

## isFinite()

template<typename ValueType>

bool juce::Rectangle< ValueType >::isFinite | ( |  | ) | const

inline noexcept

Returns true if the rectangle's values are all finite numbers, i.e.

not NaN or infinity.

References juce::juce_isfinite().

Referenced by juce::RectangleList< ValueType >::add(), juce::RectangleList< ValueType >::addWithoutMerging(), juce::RectangleList< ValueType >::clipTo(), and juce::RectangleList< ValueType >::getIntersectionWith().

## getX()

template<typename ValueType>

ValueType juce::Rectangle< ValueType >::getX | ( |  | ) | const

inline noexcept

Returns the x coordinate of the rectangle's left-hand-side.

Referenced by juce::Path::addRoundedRectangle(), juce::RectangleList< ValueType >::getBounds(), and juce::ColourGradient::horizontal().

## getY()

template<typename ValueType>

ValueType juce::Rectangle< ValueType >::getY | ( |  | ) | const

inline noexcept

Returns the y coordinate of the rectangle's top edge.

Referenced by juce::Path::addRoundedRectangle().

## getWidth()

template<typename ValueType>

ValueType juce::Rectangle< ValueType >::getWidth | ( |  | ) | const

inline noexcept

Returns the width of the rectangle.

Referenced by juce::Path::addRoundedRectangle(), and juce::LowLevelGraphicsContext::drawEllipse().

## getHeight()

template<typename ValueType>

ValueType juce::Rectangle< ValueType >::getHeight | ( |  | ) | const

inline noexcept

Returns the height of the rectangle.

Referenced by juce::Path::addRoundedRectangle(), and juce::LowLevelGraphicsContext::drawEllipse().

## getRight()

template<typename ValueType>

ValueType juce::Rectangle< ValueType >::getRight | ( |  | ) | const

inline noexcept

Returns the x coordinate of the rectangle's right-hand-side.

Referenced by enlargeIfAdjacent(), juce::ColourGradient::horizontal(), and toNearestIntEdges().

## getBottom()

template<typename ValueType>

ValueType juce::Rectangle< ValueType >::getBottom | ( |  | ) | const

inline noexcept

Returns the y coordinate of the rectangle's bottom edge.

Referenced by enlargeIfAdjacent(), and toNearestIntEdges().

## getCentreX()

template<typename ValueType>

ValueType juce::Rectangle< ValueType >::getCentreX | ( |  | ) | const

inline noexcept

Returns the x coordinate of the rectangle's centre.

## getCentreY()

template<typename ValueType>

ValueType juce::Rectangle< ValueType >::getCentreY | ( |  | ) | const

inline noexcept

Returns the y coordinate of the rectangle's centre.

## getCentre()

template<typename ValueType>

Point< ValueType > juce::Rectangle< ValueType >::getCentre | ( |  | ) | const

inline noexcept

Returns the centre point of the rectangle.

## getAspectRatio()

template<typename ValueType>

ValueType juce::Rectangle< ValueType >::getAspectRatio | ( | bool | widthOverHeight = true | ) | const

inline noexcept

Returns the aspect ratio of the rectangle's width / height.

If widthOverHeight is true, it returns width / height; if widthOverHeight is false, it returns height / width.

## getPosition()

template<typename ValueType>

Point< ValueType > juce::Rectangle< ValueType >::getPosition | ( |  | ) | const

inline noexcept

Returns the rectangle's top-left position as a Point.

## setPosition() [1/2]

template<typename ValueType>

void juce::Rectangle< ValueType >::setPosition | ( | Point< ValueType > | newPos | ) |

inline noexcept

Changes the position of the rectangle's top-left corner (leaving its size unchanged).

## setPosition() [2/2]

template<typename ValueType>

void juce::Rectangle< ValueType >::setPosition | ( | ValueType | newX,
|  | ValueType | newY )

inline noexcept

Changes the position of the rectangle's top-left corner (leaving its size unchanged).

## getTopLeft()

template<typename ValueType>

Point< ValueType > juce::Rectangle< ValueType >::getTopLeft | ( |  | ) | const

inline noexcept

Returns the rectangle's top-left position as a Point.

Referenced by intersects().

## getTopRight()

template<typename ValueType>

Point< ValueType > juce::Rectangle< ValueType >::getTopRight | ( |  | ) | const

inline noexcept

Returns the rectangle's top-right position as a Point.

Referenced by intersects().

## getBottomLeft()

template<typename ValueType>

Point< ValueType > juce::Rectangle< ValueType >::getBottomLeft | ( |  | ) | const

inline noexcept

Returns the rectangle's bottom-left position as a Point.

Referenced by intersects().

## getBottomRight()

template<typename ValueType>

Point< ValueType > juce::Rectangle< ValueType >::getBottomRight | ( |  | ) | const

inline noexcept

Returns the rectangle's bottom-right position as a Point.

Referenced by intersects().

## getHorizontalRange()

template<typename ValueType>

Range< ValueType > juce::Rectangle< ValueType >::getHorizontalRange | ( |  | ) | const

inline noexcept

Returns the rectangle's left and right positions as a Range.

References juce::Range< ValueType >::withStartAndLength().

## getVerticalRange()

template<typename ValueType>

Range< ValueType > juce::Rectangle< ValueType >::getVerticalRange | ( |  | ) | const

inline noexcept

Returns the rectangle's top and bottom positions as a Range.

References juce::Range< ValueType >::withStartAndLength().

## setSize()

template<typename ValueType>

void juce::Rectangle< ValueType >::setSize | ( | ValueType | newWidth,
|  | ValueType | newHeight )

inline noexcept

Changes the rectangle's size, leaving the position of its top-left corner unchanged.

## setBounds()

template<typename ValueType>

void juce::Rectangle< ValueType >::setBounds | ( | ValueType | newX,
|  | ValueType | newY,
|  | ValueType | newWidth,
|  | ValueType | newHeight )

inline noexcept

Changes all the rectangle's coordinates.

Referenced by expand().

## setX()

template<typename ValueType>

void juce::Rectangle< ValueType >::setX | ( | ValueType | newX | ) |

inline noexcept

Changes the rectangle's X coordinate.

## setY()

template<typename ValueType>

void juce::Rectangle< ValueType >::setY | ( | ValueType | newY | ) |

inline noexcept

Changes the rectangle's Y coordinate.

## setWidth()

template<typename ValueType>

void juce::Rectangle< ValueType >::setWidth | ( | ValueType | newWidth | ) |

inline noexcept

Changes the rectangle's width.

## setHeight()

template<typename ValueType>

void juce::Rectangle< ValueType >::setHeight | ( | ValueType | newHeight | ) |

inline noexcept

Changes the rectangle's height.

## setCentre() [1/2]

template<typename ValueType>

void juce::Rectangle< ValueType >::setCentre | ( | ValueType | newCentreX,
|  | ValueType | newCentreY )

inline noexcept

Changes the position of the rectangle's centre (leaving its size unchanged).

## setCentre() [2/2]

template<typename ValueType>

void juce::Rectangle< ValueType >::setCentre | ( | Point< ValueType > | newCentre | ) |

inline noexcept

Changes the position of the rectangle's centre (leaving its size unchanged).

References setCentre().

Referenced by setCentre().

## setHorizontalRange()

template<typename ValueType>

void juce::Rectangle< ValueType >::setHorizontalRange | ( | Range< ValueType > | range | ) |

inline noexcept

Changes the position of the rectangle's left and right edges.

## setVerticalRange()

template<typename ValueType>

void juce::Rectangle< ValueType >::setVerticalRange | ( | Range< ValueType > | range | ) |

inline noexcept

Changes the position of the rectangle's top and bottom edges.

## withX()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withX | ( | ValueType | newX | ) | const

inline nodiscard noexcept

Returns a rectangle which has the same size and y-position as this one, but with a different x-position.

References Rectangle.

## withY()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withY | ( | ValueType | newY | ) | const

inline nodiscard noexcept

Returns a rectangle which has the same size and x-position as this one, but with a different y-position.

References Rectangle.

## withRightX()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withRightX | ( | ValueType | newRightX | ) | const

inline nodiscard noexcept

Returns a rectangle which has the same size and y-position as this one, but whose right-hand edge has the given position.

References Rectangle.

## withBottomY()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withBottomY | ( | ValueType | newBottomY | ) | const

inline nodiscard noexcept

Returns a rectangle which has the same size and x-position as this one, but whose bottom edge has the given position.

References Rectangle.

## withPosition() [1/2]

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withPosition | ( | ValueType | newX,
|  | ValueType | newY ) const

inline nodiscard noexcept

Returns a rectangle with the same size as this one, but a new position.

References Rectangle.

## withPosition() [2/2]

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withPosition | ( | Point< ValueType > | newPos | ) | const

inline nodiscard noexcept

Returns a rectangle with the same size as this one, but a new position.

References Rectangle.

## withZeroOrigin()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withZeroOrigin | ( |  | ) | const

inline nodiscard noexcept

Returns a rectangle whose size is the same as this one, but whose top-left position is (0, 0).

References Rectangle.

## withCentre()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withCentre | ( | Point< ValueType > | newCentre | ) | const

inline nodiscard noexcept

Returns a rectangle with the same size as this one, but a new centre position.

References Rectangle.

## withWidth()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withWidth | ( | ValueType | newWidth | ) | const

inline nodiscard noexcept

Returns a rectangle which has the same position and height as this one, but with a different width.

References juce::jmax(), and Rectangle.

Referenced by withTrimmedRight().

## withHeight()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withHeight | ( | ValueType | newHeight | ) | const

inline nodiscard noexcept

Returns a rectangle which has the same position and width as this one, but with a different height.

References juce::jmax(), and Rectangle.

Referenced by withTrimmedBottom().

## withSize()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withSize | ( | ValueType | newWidth,
|  | ValueType | newHeight ) const

inline nodiscard noexcept

Returns a rectangle with the same top-left position as this one, but a new size.

References juce::jmax(), and Rectangle.

## withSizeKeepingCentre()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withSizeKeepingCentre | ( | ValueType | newWidth,
|  | ValueType | newHeight ) const

inline nodiscard noexcept

Returns a rectangle with the same centre position as this one, but a new size.

References Rectangle.

## setLeft()

template<typename ValueType>

void juce::Rectangle< ValueType >::setLeft | ( | ValueType | newLeft | ) |

inline noexcept

Moves the x position, adjusting the width so that the right-hand edge remains in the same place.

If the x is moved to be on the right of the current right-hand edge, the width will be set to zero.

See also
  withLeft

References juce::jmax().

## withLeft()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withLeft | ( | ValueType | newLeft | ) | const

inline nodiscard noexcept

Returns a new rectangle with a different x position, but the same right-hand edge as this one.

If the new x is beyond the right of the current right-hand edge, the width will be set to zero.

See also
  setLeft

References juce::jmax(), and Rectangle.

Referenced by withTrimmedLeft().

## setTop()

template<typename ValueType>

void juce::Rectangle< ValueType >::setTop | ( | ValueType | newTop | ) |

inline noexcept

Moves the y position, adjusting the height so that the bottom edge remains in the same place.

If the y is moved to be below the current bottom edge, the height will be set to zero.

See also
  withTop

References juce::jmax().

## withTop()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withTop | ( | ValueType | newTop | ) | const

inline nodiscard noexcept

Returns a new rectangle with a different y position, but the same bottom edge as this one.

If the new y is beyond the bottom of the current rectangle, the height will be set to zero.

See also
  setTop

References juce::jmax(), and Rectangle.

Referenced by withTrimmedTop().

## setRight()

template<typename ValueType>

void juce::Rectangle< ValueType >::setRight | ( | ValueType | newRight | ) |

inline noexcept

Adjusts the width so that the right-hand edge of the rectangle has this new value.

If the new right is below the current X value, the X will be pushed down to match it.

See also
  getRight, withRight

References juce::jmin().

## withRight()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withRight | ( | ValueType | newRight | ) | const

inline nodiscard noexcept

Returns a new rectangle with a different right-hand edge position, but the same left-hand edge as this one.

If the new right edge is below the current left-hand edge, the width will be set to zero.

See also
  setRight

References juce::jmax(), juce::jmin(), and Rectangle.

## setBottom()

template<typename ValueType>

void juce::Rectangle< ValueType >::setBottom | ( | ValueType | newBottom | ) |

inline noexcept

Adjusts the height so that the bottom edge of the rectangle has this new value.

If the new bottom is lower than the current Y value, the Y will be pushed down to match it.

See also
  getBottom, withBottom

References juce::jmin().

## withBottom()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withBottom | ( | ValueType | newBottom | ) | const

inline nodiscard noexcept

Returns a new rectangle with a different bottom edge position, but the same top edge as this one.

If the new y is beyond the bottom of the current rectangle, the height will be set to zero.

See also
  setBottom

References juce::jmax(), juce::jmin(), and Rectangle.

## withTrimmedLeft()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withTrimmedLeft | ( | ValueType | amountToRemove | ) | const

inline nodiscard noexcept

Returns a version of this rectangle with the given amount removed from its left-hand edge.

References Rectangle, and withLeft().

## withTrimmedRight()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withTrimmedRight | ( | ValueType | amountToRemove | ) | const

inline nodiscard noexcept

Returns a version of this rectangle with the given amount removed from its right-hand edge.

References Rectangle, and withWidth().

## withTrimmedTop()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withTrimmedTop | ( | ValueType | amountToRemove | ) | const

inline nodiscard noexcept

Returns a version of this rectangle with the given amount removed from its top edge.

References Rectangle, and withTop().

## withTrimmedBottom()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::withTrimmedBottom | ( | ValueType | amountToRemove | ) | const

inline nodiscard noexcept

Returns a version of this rectangle with the given amount removed from its bottom edge.

References Rectangle, and withHeight().

## translate()

template<typename ValueType>

void juce::Rectangle< ValueType >::translate | ( | ValueType | deltaX,
|  | ValueType | deltaY )

inline noexcept

Moves the rectangle's position by adding amount to its x and y coordinates.

## translated()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::translated | ( | ValueType | deltaX,
|  | ValueType | deltaY ) const

inline nodiscard noexcept

Returns a rectangle which is the same as this one moved by a given amount.

References Rectangle.

## operator+()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::operator+ | ( | Point< ValueType > | deltaPosition | ) | const

inline noexcept

Returns a rectangle which is the same as this one moved by a given amount.

References Rectangle.

## operator+=()

template<typename ValueType>

Rectangle & juce::Rectangle< ValueType >::operator+= | ( | Point< ValueType > | deltaPosition | ) |

inline noexcept

Moves this rectangle by a given amount.

References Rectangle.

## operator-()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::operator- | ( | Point< ValueType > | deltaPosition | ) | const

inline noexcept

Returns a rectangle which is the same as this one moved by a given amount.

References Rectangle.

## operator-=()

template<typename ValueType>

Rectangle & juce::Rectangle< ValueType >::operator-= | ( | Point< ValueType > | deltaPosition | ) |

inline noexcept

Moves this rectangle by a given amount.

References Rectangle.

## operator*()

template<typename ValueType>
template<typename FloatType>

Rectangle juce::Rectangle< ValueType >::operator* | ( | FloatType | scaleFactor | ) | const

inline noexcept

Returns a rectangle that has been scaled by the given amount, centred around the origin.

Note that if the rectangle has int coordinates and it's scaled by a floating-point amount, then the result will be converted back to integer coordinates using getSmallestIntegerContainer().

References Rectangle.

## operator*=() [1/2]

template<typename ValueType>
template<typename FloatType>

Rectangle juce::Rectangle< ValueType >::operator*= | ( | FloatType | scaleFactor | ) |

inline noexcept

Scales this rectangle by the given amount, centred around the origin.

Note that if the rectangle has int coordinates and it's scaled by a floating-point amount, then the result will be converted back to integer coordinates using getSmallestIntegerContainer().

References Rectangle.

## operator*=() [2/2]

template<typename ValueType>
template<typename FloatType>

Rectangle juce::Rectangle< ValueType >::operator*= | ( | Point< FloatType > | scaleFactor | ) |

inline noexcept

Scales this rectangle by the given X and Y factors, centred around the origin.

Note that if the rectangle has int coordinates and it's scaled by a floating-point amount, then the result will be converted back to integer coordinates using getSmallestIntegerContainer().

References Rectangle.

## operator/()

template<typename ValueType>
template<typename FloatType>

Rectangle juce::Rectangle< ValueType >::operator/ | ( | FloatType | scaleFactor | ) | const

inline noexcept

Scales this rectangle by the given amount, centred around the origin.

References Rectangle.

## operator/=() [1/2]

template<typename ValueType>
template<typename FloatType>

Rectangle juce::Rectangle< ValueType >::operator/= | ( | FloatType | scaleFactor | ) |

inline noexcept

Scales this rectangle by the given amount, centred around the origin.

References Rectangle.

## operator/=() [2/2]

template<typename ValueType>
template<typename FloatType>

Rectangle juce::Rectangle< ValueType >::operator/= | ( | Point< FloatType > | scaleFactor | ) |

inline noexcept

Scales this rectangle by the given X and Y factors, centred around the origin.

References Rectangle.

## expand()

template<typename ValueType>

void juce::Rectangle< ValueType >::expand | ( | ValueType | deltaX,
|  | ValueType | deltaY )

inline noexcept

Expands the rectangle by a given amount.

Effectively, its new size is (x - deltaX, y - deltaY, w + deltaX * 2, h + deltaY * 2).

See also
  expanded, reduce, reduced

References juce::jmax(), and setBounds().

Referenced by reduce().

## expanded() [1/2]

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::expanded | ( | ValueType | deltaX,
|  | ValueType | deltaY ) const

inline nodiscard noexcept

Returns a rectangle that is larger than this one by a given amount.

Effectively, the rectangle returned is (x - deltaX, y - deltaY, w + deltaX * 2, h + deltaY * 2).

See also
  expand, reduce, reduced

References juce::jmax(), and Rectangle.

Referenced by juce::LowLevelGraphicsContext::drawEllipse(), expanded(), and reduced().

## expanded() [2/2]

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::expanded | ( | ValueType | delta | ) | const

inline nodiscard noexcept

Returns a rectangle that is larger than this one by a given amount.

Effectively, the rectangle returned is (x - delta, y - delta, w + delta * 2, h + delta * 2).

See also
  expand, reduce, reduced

References expanded(), and Rectangle.

## reduce()

template<typename ValueType>

void juce::Rectangle< ValueType >::reduce | ( | ValueType | deltaX,
|  | ValueType | deltaY )

inline noexcept

Shrinks the rectangle by a given amount.

Effectively, its new size is (x + deltaX, y + deltaY, w - deltaX * 2, h - deltaY * 2).

See also
  reduced, expand, expanded

References expand().

## reduced() [1/2]

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::reduced | ( | ValueType | deltaX,
|  | ValueType | deltaY ) const

inline nodiscard noexcept

Returns a rectangle that is smaller than this one by a given amount.

Effectively, the rectangle returned is (x + deltaX, y + deltaY, w - deltaX * 2, h - deltaY * 2).

See also
  reduce, expand, expanded

References expanded(), and Rectangle.

Referenced by juce::LowLevelGraphicsContext::drawEllipse(), and reduced().

## reduced() [2/2]

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::reduced | ( | ValueType | delta | ) | const

inline nodiscard noexcept

Returns a rectangle that is smaller than this one by a given amount.

Effectively, the rectangle returned is (x + delta, y + delta, w - delta * 2, h - delta * 2).

See also
  reduce, expand, expanded

References Rectangle, and reduced().

## removeFromTop()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::removeFromTop | ( | ValueType | amountToRemove | ) |

inline noexcept

Removes a strip from the top of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (100, 100, 300, 50) and leave this rectangle as (100, 150, 300, 250).

If amountToRemove is greater than the height of this rectangle, it'll be clipped to that value.

References juce::jmin(), and Rectangle.

## removeFromLeft()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::removeFromLeft | ( | ValueType | amountToRemove | ) |

inline noexcept

Removes a strip from the left-hand edge of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (100, 100, 50, 300) and leave this rectangle as (150, 100, 250, 300).

If amountToRemove is greater than the width of this rectangle, it'll be clipped to that value.

References juce::jmin(), and Rectangle.

## removeFromRight()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::removeFromRight | ( | ValueType | amountToRemove | ) |

inline noexcept

Removes a strip from the right-hand edge of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (350, 100, 50, 300) and leave this rectangle as (100, 100, 250, 300).

If amountToRemove is greater than the width of this rectangle, it'll be clipped to that value.

References juce::jmin(), and Rectangle.

## removeFromBottom()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::removeFromBottom | ( | ValueType | amountToRemove | ) |

inline noexcept

Removes a strip from the bottom of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (100, 350, 300, 50) and leave this rectangle as (100, 100, 300, 250).

If amountToRemove is greater than the height of this rectangle, it'll be clipped to that value.

References juce::jmin(), and Rectangle.

## getConstrainedPoint()

template<typename ValueType>

Point< ValueType > juce::Rectangle< ValueType >::getConstrainedPoint | ( | Point< ValueType > | point | ) | const

inline noexcept

Returns the nearest point to the specified point that lies within this rectangle.

References juce::jlimit().

## getRelativePoint()

template<typename ValueType>
template<typename FloatType>

Point< ValueType > juce::Rectangle< ValueType >::getRelativePoint | ( | FloatType | relativeX,
|  | FloatType | relativeY ) const

inline noexcept

Returns a point within this rectangle, specified as proportional coordinates.

The relative X and Y values should be between 0 and 1, where 0 is the left or top of this rectangle, and 1 is the right or bottom. (Out-of-bounds values will return a point outside the rectangle).

## proportionOfWidth()

template<typename ValueType>
template<typename FloatType>

ValueType juce::Rectangle< ValueType >::proportionOfWidth | ( | FloatType | proportion | ) | const

inline noexcept

Returns a proportion of the width of this rectangle.

Referenced by getProportion().

## proportionOfHeight()

template<typename ValueType>
template<typename FloatType>

ValueType juce::Rectangle< ValueType >::proportionOfHeight | ( | FloatType | proportion | ) | const

inline noexcept

Returns a proportion of the height of this rectangle.

Referenced by getProportion().

## getProportion()

template<typename ValueType>
template<typename FloatType>

Rectangle juce::Rectangle< ValueType >::getProportion | ( | Rectangle< FloatType > | proportionalRect | ) | const

inline noexcept

Returns a rectangle based on some proportional coordinates relative to this one.

So for example getProportion ({ 0.25f, 0.25f, 0.5f, 0.5f }) would return a rectangle of half the original size, with the same centre.

References proportionOfHeight(), proportionOfWidth(), and Rectangle.

## operator==()

template<typename ValueType>

bool juce::Rectangle< ValueType >::operator== | ( | const Rectangle< ValueType > & | other | ) | const

inline noexcept

Returns true if the two rectangles are identical.

References Rectangle.

Referenced by operator!=().

## operator!=()

template<typename ValueType>

bool juce::Rectangle< ValueType >::operator!= | ( | const Rectangle< ValueType > & | other | ) | const

inline noexcept

Returns true if the two rectangles are not identical.

References operator==(), and Rectangle.

## contains() [1/3]

template<typename ValueType>

bool juce::Rectangle< ValueType >::contains | ( | ValueType | xCoord,
|  | ValueType | yCoord ) const

inline noexcept

Returns true if this coordinate is inside the rectangle.

Referenced by juce::RectangleList< ValueType >::add(), and intersects().

## contains() [2/3]

template<typename ValueType>

bool juce::Rectangle< ValueType >::contains | ( | Point< ValueType > | point | ) | const

inline noexcept

Returns true if this coordinate is inside the rectangle.

## contains() [3/3]

template<typename ValueType>

bool juce::Rectangle< ValueType >::contains | ( | Rectangle< ValueType > | other | ) | const

inline noexcept

Returns true if this other rectangle is completely inside this one.

References Rectangle.

## intersects() [1/2]

template<typename ValueType>

bool juce::Rectangle< ValueType >::intersects | ( | Rectangle< ValueType > | other | ) | const

inline noexcept

Returns true if any part of another rectangle overlaps this one.

References Rectangle.

Referenced by juce::RectangleList< ValueType >::add().

## intersects() [2/2]

template<typename ValueType>

bool juce::Rectangle< ValueType >::intersects | ( | const Line< ValueType > & | line | ) | const

inline noexcept

Returns true if any part of the given line lies inside this rectangle.

References contains(), getBottomLeft(), getBottomRight(), getTopLeft(), and getTopRight().

## getIntersection()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::getIntersection | ( | Rectangle< ValueType > | other | ) | const

inline noexcept

Returns the region that is the overlap between this and another rectangle.

If the two rectangles don't overlap, the rectangle returned will be empty.

References juce::jmax(), juce::jmin(), and Rectangle.

## intersectRectangle() [1/2]

template<typename ValueType>

bool juce::Rectangle< ValueType >::intersectRectangle | ( | ValueType & | otherX,
|  | ValueType & | otherY,
|  | ValueType & | otherW,
|  | ValueType & | otherH ) const

inline noexcept

Clips a set of rectangle coordinates so that they lie only within this one.

This is a non-static version of intersectRectangles(). Returns false if the two rectangles didn't overlap.

References juce::jmax(), and juce::jmin().

Referenced by juce::RectangleList< ValueType >::clipTo(), juce::RectangleList< ValueType >::getIntersectionWith(), and intersectRectangle().

## intersectRectangle() [2/2]

template<typename ValueType>

bool juce::Rectangle< ValueType >::intersectRectangle | ( | Rectangle< ValueType > & | rectangleToClip | ) | const

inline noexcept

Clips a rectangle so that it lies only within this one.

Returns false if the two rectangles didn't overlap.

References intersectRectangle(), and Rectangle.

## getUnion()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::getUnion | ( | Rectangle< ValueType > | other | ) | const

inline noexcept

Returns the smallest rectangle that contains both this one and the one passed-in.

If either this or the other rectangle are empty, they will not be counted as part of the resulting region.

References isEmpty(), juce::jmax(), juce::jmin(), and Rectangle.

## enlargeIfAdjacent()

template<typename ValueType>

bool juce::Rectangle< ValueType >::enlargeIfAdjacent | ( | Rectangle< ValueType > | other | ) |

inline noexcept

If this rectangle merged with another one results in a simple rectangle, this will set this rectangle to the result, and return true.

Returns false and does nothing to this rectangle if the two rectangles don't overlap, or if they form a complex region.

References juce::exactlyEqual(), getBottom(), getRight(), juce::jmax(), juce::jmin(), and Rectangle.

## reduceIfPartlyContainedIn()

template<typename ValueType>

bool juce::Rectangle< ValueType >::reduceIfPartlyContainedIn | ( | Rectangle< ValueType > | other | ) |

inline noexcept

If after removing another rectangle from this one the result is a simple rectangle, this will set this object's bounds to be the result, and return true.

Returns false and does nothing to this rectangle if the two rectangles don't overlap, or if removing the other one would form a complex region.

References Rectangle.

## constrainedWithin()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::constrainedWithin | ( | Rectangle< ValueType > | areaToFitWithin | ) | const

inline noexcept

Tries to fit this rectangle within a target area, returning the result.

If this rectangle is not completely inside the target area, then it'll be shifted (without changing its size) so that it lies within the target. If it is larger than the target rectangle in either dimension, then that dimension will be reduced to fit within the target.

References juce::jmin(), and Rectangle.

## transformedBy()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::transformedBy | ( | const AffineTransform & | transform | ) | const

inline nodiscard noexcept

Returns the smallest rectangle that can contain the shape created by applying a transform to this rectangle.

This should only be used on floating point rectangles.

References juce::jmax(), juce::jmin(), and Rectangle.

## getSmallestIntegerContainer()

template<typename ValueType>

Rectangle< int > juce::Rectangle< ValueType >::getSmallestIntegerContainer | ( |  | ) | const

inline noexcept

Returns the smallest integer-aligned rectangle that completely contains this one.

This is only relevant for floating-point rectangles, of course.

See also
  toFloat(), toNearestInt(), toNearestIntEdges(), getLargestIntegerWithin()

References leftTopRightBottom(), and Rectangle.

## getLargestIntegerWithin()

template<typename ValueType>

Rectangle< int > juce::Rectangle< ValueType >::getLargestIntegerWithin | ( |  | ) | const

inline noexcept

Returns the largest integer-aligned rectangle that is completely contained by this one.

Returns an empty rectangle, outside the original rectangle, if no integer-aligned rectangle is contained by this one. This is only relevant for floating-point rectangles, of course.

See also
  toFloat(), toNearestInt(), toNearestIntEdges(), getSmallestIntegerContainer()

References juce::jmax(), and Rectangle.

## toNearestInt()

template<typename ValueType>

Rectangle< int > juce::Rectangle< ValueType >::toNearestInt | ( |  | ) | const

inline noexcept

Casts this rectangle to a Rectangle<int>.

This uses roundToInt to snap x, y, width and height to the nearest integer (losing precision). If the rectangle already uses integers, this will simply return a copy.

See also
  getSmallestIntegerContainer(), toNearestIntEdges()

References Rectangle, and juce::roundToInt().

Referenced by juce::StandaloneFilterWindow::StandaloneFilterWindow().

## toNearestIntEdges()

template<typename ValueType>

Rectangle< int > juce::Rectangle< ValueType >::toNearestIntEdges | ( |  | ) | const

inline noexcept

Casts this rectangle to a Rectangle<int>.

This uses roundToInt to snap top, left, right and bottom to the nearest integer (losing precision). If the rectangle already uses integers, this will simply return a copy.

See also
  getSmallestIntegerContainer(), toNearestInt()

References getBottom(), getRight(), leftTopRightBottom(), Rectangle, and juce::roundToInt().

## toFloat()

template<typename ValueType>

Rectangle< float > juce::Rectangle< ValueType >::toFloat | ( |  | ) | const

inline noexcept

Casts this rectangle to a Rectangle<float>.

See also
  getSmallestIntegerContainer

References Rectangle.

## toDouble()

template<typename ValueType>

Rectangle< double > juce::Rectangle< ValueType >::toDouble | ( |  | ) | const

inline noexcept

Casts this rectangle to a Rectangle<double>.

See also
  getSmallestIntegerContainer

References Rectangle.

## toType()

template<typename ValueType>
template<typename TargetType>

Rectangle< TargetType > juce::Rectangle< ValueType >::toType | ( |  | ) | const

inline noexcept

Casts this rectangle to a Rectangle with the given type.

If the target type is a conversion from float to int, then the conversion will be done using getSmallestIntegerContainer().

References Rectangle.

## findAreaContainingPoints()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::findAreaContainingPoints | ( | const Point< ValueType > * | points,
|  | int | numPoints )

inline static noexcept

Returns the smallest Rectangle that can contain a set of points.

References juce::jmax(), juce::jmin(), Rectangle, x, and y.

Referenced by juce::Parallelogram< ValueType >::getBoundingBox().

## intersectRectangles()

template<typename ValueType>

bool juce::Rectangle< ValueType >::intersectRectangles | ( | ValueType & | x1,
|  | ValueType & | y1,
|  | ValueType & | w1,
|  | ValueType & | h1,
|  | ValueType | x2,
|  | ValueType | y2,
|  | ValueType | w2,
|  | ValueType | h2 )

inline static noexcept

Static utility to intersect two sets of rectangular coordinates.

Returns false if the two regions didn't overlap.

See also
  intersectRectangle

References juce::jmax(), juce::jmin(), x, and y.

## toString()

template<typename ValueType>

String juce::Rectangle< ValueType >::toString | ( |  | ) | const

inline

Creates a string describing this rectangle.

The string will be of the form "x y width height", e.g. "100 100 400 200".

Coupled with the fromString() method, this is very handy for things like storing rectangles (particularly component positions) in XML attributes.

See also
  fromString

References juce::String::preallocateBytes().

## fromString()

template<typename ValueType>

Rectangle juce::Rectangle< ValueType >::fromString | ( | StringRef | stringVersion | ) |

inline static

Parses a string containing a rectangle's details.

The string should contain 4 numeric tokens, in the form "x y width height". They can be comma or whitespace separated.

This method is intended to go with the toString() method, to form an easy way of saving/loading rectangles as strings.

See also
  toString

References juce::StringArray::addTokens(), juce::CharPointer_UTF8::findEndOfWhitespace(), Rectangle, and juce::StringRef::text.

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited