mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added helper method Rectangle::toNearestInt().
This commit is contained in:
parent
3d341b8ca1
commit
26759d5f64
1 changed files with 12 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue