Tweeny 4.1.0
A Tweening library for modern C++
Loading...
Searching...
No Matches
key-frame.h
1/*
2This file is part of the Tweeny library.
3
4Copyright (c) 2016-2026 Leonardo Guilherme Lucena de Freitas
5Copyright (c) 2016 Guilherme R. Costa
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of
8this software and associated documentation files (the "Software"), to deal in
9the Software without restriction, including without limitation the rights to
10use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11the Software, and to permit persons to whom the Software is furnished to do so,
12subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23*/
24
25#ifndef TWEENY_DETAIL_KEY_FRAME_H
26#define TWEENY_DETAIL_KEY_FRAME_H
27
28
29#include <algorithm>
30
31#include "value-container.h"
32
33#include <cstdint>
34#include <functional>
35#include <tuple>
36
37namespace tweeny::detail {
38 template<typename... ValueTypes>
48 struct key_frame {
49 typedef value_container_t<ValueTypes...> values_t;
50 typedef std::tuple<std::function<ValueTypes(float, ValueTypes, ValueTypes)>...> value_easing_functions_t;
51 typedef std::array<uint32_t, sizeof...(ValueTypes)> value_tween_frame_counts_t;
52
65 explicit key_frame(ValueTypes... vs) : position(0), values{vs...}, easing_functions(), tween_frame_counts() {}
66
67
75 uint32_t position;
76
87 values_t values;
88
101 value_easing_functions_t easing_functions;
102
115 value_tween_frame_counts_t tween_frame_counts;
116
125 [[nodiscard]] uint32_t highest_frame_count() const {
126 return *std::max_element(tween_frame_counts.begin(), tween_frame_counts.end());
127 }
128 };
129}
130
131#endif //TWEENY_DETAIL_KEY_FRAME_H
key_frame(ValueTypes... vs)
Constructs a key_frame object initialized with provided values.
Definition key-frame.h:65
value_easing_functions_t easing_functions
Definition key-frame.h:101
uint32_t highest_frame_count() const
Retrieves the highest frame count from the tween_frame_counts array.
Definition key-frame.h:125
value_container_t< ValueTypes... > values_t
Represents a container to store values in key_frame.
Definition key-frame.h:49
value_tween_frame_counts_t tween_frame_counts
Definition key-frame.h:115