29bool RectanglePlacement::operator== (
const RectanglePlacement&
other)
const noexcept
31 return flags ==
other.flags;
34bool RectanglePlacement::operator!= (
const RectanglePlacement&
other)
const noexcept
36 return flags !=
other.flags;
40 const double dx,
const double dy,
const double dw,
const double dh)
const noexcept
45 if ((flags & stretchToFit) != 0)
54 double scale = (flags & fillDestination) != 0 ?
jmax (
dw / w,
dh / h)
57 if ((flags & onlyReduceInSize) != 0)
58 scale =
jmin (scale, 1.0);
60 if ((flags & onlyIncreaseInSize) != 0)
61 scale =
jmax (scale, 1.0);
66 if ((flags & xLeft) != 0)
68 else if ((flags & xRight) != 0)
71 x =
dx + (
dw - w) * 0.5;
73 if ((flags & yTop) != 0)
75 else if ((flags & yBottom) != 0)
78 y = dy + (
dh - h) * 0.5;
87 float newX = destination.getX();
88 float newY = destination.getY();
90 float scaleX = destination.getWidth() / source.getWidth();
91 float scaleY = destination.getHeight() / source.getHeight();
93 if ((flags & stretchToFit) == 0)
98 if ((flags & onlyReduceInSize) != 0)
101 if ((flags & onlyIncreaseInSize) != 0)
106 if ((flags & xRight) != 0)
107 newX += destination.getWidth() - source.getWidth() *
scaleX;
108 else if ((flags & xLeft) == 0)
109 newX += (destination.getWidth() - source.getWidth() *
scaleX) / 2.0f;
111 if ((flags & yBottom) != 0)
112 newY += destination.getHeight() - source.getHeight() *
scaleX;
113 else if ((flags & yTop) == 0)
114 newY += (destination.getHeight() - source.getHeight() *
scaleX) / 2.0f;
AffineTransform getTransformToFit(const Rectangle< float > &source, const Rectangle< float > &destination) const noexcept
Returns the transform that should be applied to these source coordinates to fit them into the destina...
void applyTo(double &sourceX, double &sourceY, double &sourceW, double &sourceH, double destinationX, double destinationY, double destinationW, double destinationH) const noexcept
Adjusts the position and size of a rectangle to fit it into a space.
Manages a rectangle and allows geometric operations to be performed on it.
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
Returns true if the two floating-point numbers are approximately equal.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...