8 #include <SFML/System/Clock.hpp> 10 #include <NasNas/tween/Easing.hpp> 16 explicit Tween() =
default;
20 auto loop() ->
Tween&;
22 auto after(
float delay) ->
Tween&;
24 auto from_to(
float start,
float end) ->
Tween&;
26 auto to(
float end) ->
Tween&;
28 auto during(
float duration) ->
Tween&;
30 auto apply(tween::CallbackFunction callback) ->
Tween&;
32 auto with(tween::EasingFunction
function) ->
Tween&;
34 auto delay(
float delay) ->
Tween&;
36 void onEnd(std::function<
void()> fn);
40 auto ended()
const -> bool;
46 std::vector<float> m_starts;
47 std::vector<float> m_ends;
48 std::vector<float> m_durations = {1.f};
49 std::vector<float> m_delays = {0.f};
50 std::vector<tween::EasingFunction> m_easing_fns = {easing::linear};
51 std::vector<tween::CallbackFunction> m_on_step_cbs = {[](float){}};
52 std::function<void()> m_on_end_cb = []{};
54 float m_initial_delay = 0.f;
55 float m_current_delay = 0.f;
56 bool m_first_run =
true;
57 bool m_on_end_called =
false;
60 inline auto interpolate(
unsigned i,
float x)
const ->
float {
61 return (m_ends[i] - m_starts[i]) * x + m_starts[i];
64 void emplaceAnimation();