12template<
typename T, ColorSpace Space>
14 requires detail::PositionalGeometric<T>
20template<
typename T, ColorSpace Space>
24 return QRectF(anchor, sweptSizeImpl().second);
28template<
typename T, ColorSpace Space>
30 requires detail::SizeGeometric<T>
32 return sweptSizeImpl();
36template<
typename T, ColorSpace Space>
38 requires std::same_as<T, QRectF>
40 return qAbs(m_current.width() - m_to.width()) > epsilonPx || qAbs(m_current.height() - m_to.height()) > epsilonPx;
44template<
typename T, ColorSpace Space>
46 requires detail::ScalarValue<T>
48 return sweptRangeImpl();
55template<
typename T, ColorSpace Space>
57 requires detail::PositionalGeometric<T>
59 qreal minX, minY, maxX, maxY;
60 if constexpr (std::same_as<T, QPointF>) {
61 minX = std::min(m_from.x(), m_to.x());
62 maxX = std::max(m_from.x(), m_to.x());
63 minY = std::min(m_from.y(), m_to.y());
64 maxY = std::max(m_from.y(), m_to.y());
65 sampleOvershoots(minX, minY, maxX, maxY, [
this](qreal p) {
67 return std::tuple<qreal, qreal, qreal, qreal>{s.x(), s.y(), s.x(), s.y()};
70 minX = std::min(m_from.left(), m_to.left());
71 minY = std::min(m_from.top(), m_to.top());
72 maxX = std::max(m_from.right(), m_to.right());
73 maxY = std::max(m_from.bottom(), m_to.bottom());
74 sampleOvershoots(minX, minY, maxX, maxY, [
this](qreal p) {
75 const QRectF s = Interpolate<QRectF>::lerp(m_from, m_to, p);
76 return std::tuple<qreal, qreal, qreal, qreal>{s.left(), s.top(), s.right(), s.bottom()};
79 return QRectF(minX, minY, maxX - minX, maxY - minY);
82template<
typename T, ColorSpace Space>
83std::pair<QSizeF, QSizeF> AnimatedValue<T, Space>::sweptSizeImpl() const
84 requires detail::SizeGeometric<T>
86 qreal minW = std::min(m_from.width(), m_to.width());
87 qreal maxW = std::max(m_from.width(), m_to.width());
88 qreal minH = std::min(m_from.height(), m_to.height());
89 qreal maxH = std::max(m_from.height(), m_to.height());
90 const auto curve = effectiveCurve();
91 if (curve && curve->overshoots()) {
92 for (
int i = 1; i < kOvershootSamples; ++i) {
97 const QSizeF sampled = Interpolate<QSizeF>::lerp(m_from, m_to, p);
98 minW = std::min(minW, sampled.width());
99 maxW = std::max(maxW, sampled.width());
100 minH = std::min(minH, sampled.height());
101 maxH = std::max(maxH, sampled.height());
104 return {QSizeF(minW, minH), QSizeF(maxW, maxH)};
107template<
typename T, ColorSpace Space>
108template<
typename Sampler>
109void AnimatedValue<T, Space>::sampleOvershoots(qreal& minX, qreal& minY, qreal& maxX, qreal& maxY,
110 const Sampler& sampleAt)
const
112 const auto curve = effectiveCurve();
113 if (!curve || !curve->overshoots()) {
116 for (
int i = 1; i < kOvershootSamples; ++i) {
118 const auto [x1, y1, x2, y2] = sampleAt(p);
119 minX = std::min(minX, x1);
120 minY = std::min(minY, y1);
121 maxX = std::max(maxX, x2);
122 maxY = std::max(maxY, y2);
126template<
typename T, ColorSpace Space>
127std::pair<T, T> AnimatedValue<T, Space>::sweptRangeImpl()
const
129 T lo = std::min(m_from, m_to);
130 T hi = std::max(m_from, m_to);
131 const auto curve = effectiveCurve();
132 if (curve && curve->overshoots()) {
133 for (
int i = 1; i < kOvershootSamples; ++i) {
137 const T sampled = Interpolate<T>::lerp(m_from, m_to, p);
138 lo = std::min(lo, sampled);
139 hi = std::max(hi, sampled);
Unified motion primitive: one value of type T transitioning from start to target over time,...
Definition AnimatedValue.h:45
bool hasSizeChange(qreal epsilonPx=kRectSizeEpsilonPx) const
True when current size diverges from target by > epsilonPx on either axis.
Definition AnimatedValue_geometric.h:37
std::pair< T, T > sweptRange() const
(lo, hi) of a scalar animation's swept range, with overshoot.
Definition AnimatedValue_geometric.h:45
QRectF bounds() const
Bounding rectangle of the swept path including curve overshoot.
Definition AnimatedValue_geometric.h:13
QRectF boundsAt(QPointF anchor) const
Damage rect anchored at anchor — QSizeF specialisation only.
Definition AnimatedValue_geometric.h:21
std::pair< QSizeF, QSizeF > sweptSize() const
(minSize, maxSize) the animation sweeps through, including overshoot.
Definition AnimatedValue_geometric.h:29
Size-only T — caller must supply an anchor for damage rect.
Definition Interpolate.h:400
Definition AnimatedValue.h:32
qreal boundCurveProgress(qreal progress)
Bound a curve's output to the overshoot envelope [Limits::MinCurveProgress, Limits::MaxCurveProgress]...
Definition Curve.h:118
Type-specific linear interpolation and path-distance for AnimatedValue<T>.
Definition Interpolate.h:36