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) {
93 const qreal p = curve->evaluate(qreal(i) / kOvershootSamples);
94 const QSizeF sampled = Interpolate<QSizeF>::lerp(m_from, m_to, p);
95 minW = std::min(minW, sampled.width());
96 maxW = std::max(maxW, sampled.width());
97 minH = std::min(minH, sampled.height());
98 maxH = std::max(maxH, sampled.height());
101 return {QSizeF(minW, minH), QSizeF(maxW, maxH)};
104template<
typename T, ColorSpace Space>
105template<
typename Sampler>
106void AnimatedValue<T, Space>::sampleOvershoots(qreal& minX, qreal& minY, qreal& maxX, qreal& maxY,
107 const Sampler& sampleAt)
const
109 const auto curve = effectiveCurve();
110 if (!curve || !curve->overshoots()) {
113 for (
int i = 1; i < kOvershootSamples; ++i) {
114 const qreal p = curve->evaluate(qreal(i) / kOvershootSamples);
115 const auto [x1, y1, x2, y2] = sampleAt(p);
116 minX = std::min(minX, x1);
117 minY = std::min(minY, y1);
118 maxX = std::max(maxX, x2);
119 maxY = std::max(maxY, y2);
123template<
typename T, ColorSpace Space>
124std::pair<T, T> AnimatedValue<T, Space>::sweptRangeImpl()
const
126 T lo = std::min(m_from, m_to);
127 T hi = std::max(m_from, m_to);
128 const auto curve = effectiveCurve();
129 if (curve && curve->overshoots()) {
130 for (
int i = 1; i < kOvershootSamples; ++i) {
131 const qreal p = curve->evaluate(qreal(i) / kOvershootSamples);
132 const T sampled = Interpolate<T>::lerp(m_from, m_to, p);
133 lo = std::min(lo, sampled);
134 hi = std::max(hi, sampled);
Unified motion primitive: one value of type T transitioning from start to target over time,...
Definition AnimatedValue.h:44
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:31
Type-specific linear interpolation and path-distance for AnimatedValue<T>.
Definition Interpolate.h:36