29#ifndef DOXYGEN_SHOULD_SKIP_THIS
45 using Setter = std::function<void(
const T&)>;
61 , m_duration(duration)
79 , m_setter([&value](const
T& newValue) { value = newValue; })
81 , m_duration(duration)
129 m_duration = duration;
147 return gf::lerp(m_origin, m_target, m_easing(m_elapsed.asSeconds() / m_duration.asSeconds()));
156 return m_elapsed >= m_duration;
167 if (m_elapsed >= m_duration) {
168 m_elapsed = m_duration;
171 m_setter(getValue());
190#ifndef DOXYGEN_SHOULD_SKIP_THIS
static float linear(float t)
Linear easing.
Represents a time value.
Definition: Time.h:65
static constexpr Time zero()
Get a time of zero.
Definition: Time.h:167
An interpolation between two values.
Definition: Tween.h:40
std::function< void(const T &)> Setter
A setter function.
Definition: Tween.h:45
constexpr Time getDuration() const noexcept
Get the duration of the tween.
Definition: Tween.h:137
void restart()
Restart the tween.
Definition: Tween.h:177
Tween(T origin, T target, Setter setter, Time duration, Easing easing=Ease::linear)
Constructor with a setter.
Definition: Tween.h:56
bool isFinished() const
Check if the tween is finished.
Definition: Tween.h:155
constexpr T getTarget() const noexcept
Get the target of the tween.
Definition: Tween.h:119
void setDuration(Time duration)
Change the duration of the tween.
Definition: Tween.h:128
void setOrigin(T origin)
Change the origin of the tween.
Definition: Tween.h:92
void setTarget(T target)
Change the target of the tween.
Definition: Tween.h:110
void update(Time time)
Update the tween.
Definition: Tween.h:164
Tween(T origin, T target, T &value, Time duration, Easing easing=Ease::linear)
Constructor with a reference.
Definition: Tween.h:76
T getValue() const
Get the current value of the tween.
Definition: Tween.h:146
constexpr T getOrigin() const noexcept
Get the origin of the tween.
Definition: Tween.h:101
float(*)(float) Easing
An easing function.
Definition: Easings.h:48
constexpr T lerp(T lhs, T rhs, U t)
Linear interpolation function.
Definition: Math.h:266
The namespace for gf classes.