Tweeny 4.2.0
A Tweening library for modern C++
Loading...
Searching...
No Matches

◆ keyframe()

template<typename FirstValueType, typename... RemainingValueTypes>
auto keyframe ( ) const -> std::size_t
nodiscard

Returns the index of the keyframe segment the tween is currently in.

The index identifies the keyframe the current frame has most recently reached or passed: 0 while between the first and second keyframes, 1 between the second and third, and so on. At the very end of the tween it is the index of the last keyframe, matching jump(). It is updated before any listener runs, so it is safe to read from inside step, seek, jump, update, and complete callbacks.

Returns
Zero-based index of the current keyframe
auto t = tweeny::from(0).to(50).during(30U).to(100).during(30U).build();
t.on(event::step, [](auto& tween) {
printf("In keyframe %zu\n", tween.keyframe());
});
t.step(10); // Prints: "In keyframe 0"
t.step(25); // Prints: "In keyframe 1"
tween(const key_frames_t &key_frames_input)
Constructs a tween from keyframes (use builder API instead).
tweeny_builder< true, FirstValue, RemainingValues... > to(const FirstValue &firstComponent, const RemainingValues &... remainingComponents) &
Adds a target keyframe to the tween.
Definition tweeny.h:109
tweeny_builder & during(FrameCountsType... frame_counts)
Specifies per-component frame durations for the last keyframe segment.
Definition tweeny.h:245
@ ok
Continue receiving events.
Definition detail/event.h:108
constexpr detail::event::step_t step
Event triggered after each step() call.
Definition event.h:83
tweeny_builder< false, FirstValue, RemainingValues... > from(FirstValue firstComponent, RemainingValues... remainingComponents)
Creates a new tween builder starting from the specified value(s).
Definition tweeny.h:347