|
|
@@ -794,7 +794,7 @@ public: |
|
|
*/
|
|
|
*/
|
|
|
Rectangle transformedBy (const AffineTransform& transform) const noexcept
|
|
|
Rectangle transformedBy (const AffineTransform& transform) const noexcept
|
|
|
{
|
|
|
{
|
|
|
typedef typename TypeHelpers::SmallestFloatType<ValueType>::type FloatType;
|
|
|
|
|
|
|
|
|
using FloatType = typename TypeHelpers::SmallestFloatType<ValueType>::type;
|
|
|
|
|
|
|
|
|
auto x1 = static_cast<FloatType> (pos.x), y1 = static_cast<FloatType> (pos.y);
|
|
|
auto x1 = static_cast<FloatType> (pos.x), y1 = static_cast<FloatType> (pos.y);
|
|
|
auto x2 = static_cast<FloatType> (pos.x + w), y2 = static_cast<FloatType> (pos.y);
|
|
|
auto x2 = static_cast<FloatType> (pos.x + w), y2 = static_cast<FloatType> (pos.y);
|
|
|
@@ -816,7 +816,7 @@ public: |
|
|
|
|
|
|
|
|
/** Returns the smallest integer-aligned rectangle that completely contains this one.
|
|
|
/** Returns the smallest integer-aligned rectangle that completely contains this one.
|
|
|
This is only relevant for floating-point rectangles, of course.
|
|
|
This is only relevant for floating-point rectangles, of course.
|
|
|
@see toFloat(), toNearestInt()
|
|
|
|
|
|
|
|
|
@see toFloat(), toNearestInt(), toNearestIntEdges()
|
|
|
*/
|
|
|
*/
|
|
|
Rectangle<int> getSmallestIntegerContainer() const noexcept
|
|
|
Rectangle<int> getSmallestIntegerContainer() const noexcept
|
|
|
{
|
|
|
{
|
|
|
@@ -829,7 +829,7 @@ public: |
|
|
/** Casts this rectangle to a Rectangle<int>.
|
|
|
/** Casts this rectangle to a Rectangle<int>.
|
|
|
This uses roundToInt to snap x, y, width and height to the nearest integer (losing precision).
|
|
|
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.
|
|
|
If the rectangle already uses integers, this will simply return a copy.
|
|
|
@see getSmallestIntegerContainer()
|
|
|
|
|
|
|
|
|
@see getSmallestIntegerContainer(), toNearestIntEdges()
|
|
|
*/
|
|
|
*/
|
|
|
Rectangle<int> toNearestInt() const noexcept
|
|
|
Rectangle<int> toNearestInt() const noexcept
|
|
|
{
|
|
|
{
|
|
|
@@ -837,6 +837,17 @@ public: |
|
|
roundToInt (w), roundToInt (h) };
|
|
|
roundToInt (w), roundToInt (h) };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 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 getSmallestIntegerContainer(), toNearestInt()
|
|
|
|
|
|
*/
|
|
|
|
|
|
Rectangle<int> toNearestIntEdges() const noexcept
|
|
|
|
|
|
{
|
|
|
|
|
|
return Rectangle<int>::leftTopRightBottom (roundToInt (pos.x), roundToInt (pos.y),
|
|
|
|
|
|
roundToInt (getRight()), roundToInt (getBottom()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/** Casts this rectangle to a Rectangle<float>.
|
|
|
/** Casts this rectangle to a Rectangle<float>.
|
|
|
@see getSmallestIntegerContainer
|
|
|
@see getSmallestIntegerContainer
|
|
|
*/
|
|
|
*/
|
|
|
|