Browse Source

Added helper method Rectangle::toNearestInt().

tags/2021-05-28
Timur Doumler 10 years ago
parent
commit
26759d5f64
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      modules/juce_graphics/geometry/juce_Rectangle.h

+ 12
- 1
modules/juce_graphics/geometry/juce_Rectangle.h View File

@@ -774,7 +774,7 @@ public:
/** Returns the smallest integer-aligned rectangle that completely contains this one.
This is only relevent for floating-point rectangles, of course.
@see toFloat()
@see toFloat(), toNearestInt()
*/
Rectangle<int> getSmallestIntegerContainer() const noexcept
{
@@ -786,6 +786,17 @@ public:
return Rectangle<int> (x1, y1, x2 - x1, y2 - y1);
}
/** Casts this rectangle to a Rectangle<int>.
This uses roundToInt for rounding the bounds (if this rectangle uses floating point)
or just returns a copy (if this rectangle uses integers as well).
@see getSmallestIntegerContainer()
*/
Rectangle<int> toNearestInt() const noexcept
{
return Rectangle<int> (roundToInt (pos.x), roundToInt (pos.y),
roundToInt (w), roundToInt (h));
}
/** Casts this rectangle to a Rectangle<float>.
@see getSmallestIntegerContainer
*/


Loading…
Cancel
Save