PixelKey
NeoPixel USB Key
Loading...
Searching...
No Matches
keyframe_fade.h
1#ifndef KEYFRAME_FADE_H
2#define KEYFRAME_FADE_H
3
4#include <stdlib.h>
5#include <stdint.h>
6#include <stdbool.h>
7
8#include "color.h"
9#include "keyframes.h"
10
19#define KEYFRAME_FADE_COLORS_INPUT_MAX_LENGTH (15)
20
25#define KEYFRAME_FADE_COLORS_MAX_LENGTH (KEYFRAME_FADE_COLORS_INPUT_MAX_LENGTH + 1)
26
27
31typedef enum e_fade_type
32{
36
40typedef enum e_fade_axis
41{
43 FADE_AXIS_HUE = (1U << 0),
44 FADE_AXIS_SAT = (1U << 1),
45 FADE_AXIS_VAL = (1U << 2)
47
51typedef struct st_point
52{
53 float x;
54 float y;
55} point_t;
56
60typedef struct st_cubic_bezier
61{
65
69typedef struct st_keyframe_fade
70{
72 keyframe_base_t base;
74 struct
75 {
76 float period;
80 uint8_t colors_len;
82 } args;
84 struct
85 {
89 uint8_t pair_index;
92 } state;
94
95extern const cubic_bezier_t cb_linear;
96extern const cubic_bezier_t cb_ease;
97extern const cubic_bezier_t cb_ease_in;
98extern const cubic_bezier_t cb_ease_out;
99extern const cubic_bezier_t cb_ease_in_out;
100
103#endif
const cubic_bezier_t cb_ease_in_out
Control points for ease-in-out fade.
Definition: keyframe_fade.c:57
const cubic_bezier_t cb_linear
Control points for linear fade.
Definition: keyframe_fade.c:49
const cubic_bezier_t cb_ease_out
Control points for ease-out fade.
Definition: keyframe_fade.c:55
fade_axis_t
The color axes/channels to fade over.
Definition: keyframe_fade.h:41
const cubic_bezier_t cb_ease
Control points for ease fade.
Definition: keyframe_fade.c:51
fade_type_t
The type of fade to perform.
Definition: keyframe_fade.h:32
#define KEYFRAME_FADE_COLORS_MAX_LENGTH
Maximum number of colors that can be faded in one keyframe.
Definition: keyframe_fade.h:25
const cubic_bezier_t cb_ease_in
Control points for ease-in fade.
Definition: keyframe_fade.c:53
@ FADE_AXIS_SAT
Fade is needed for the Saturation axis.
Definition: keyframe_fade.h:44
@ FADE_AXIS_HUE
Fade is needed for the Hue axis.
Definition: keyframe_fade.h:43
@ FADE_AXIS_NONE
No axis require fading.
Definition: keyframe_fade.h:42
@ FADE_AXIS_VAL
Fade if needed for the Value axis.
Definition: keyframe_fade.h:45
@ FADE_TYPE_CUBIC
The transition curve is applied between every pair of colors.
Definition: keyframe_fade.h:34
@ FADE_TYPE_STEP
Colors are immediately transitioned.
Definition: keyframe_fade.h:33
uint8_t framerate_t
Number of frames per second.
Definition: keyframes.h:55
uint32_t timestep_t
The base unit of time for animating keyframes; resolution of 1 frame.
Definition: keyframes.h:52
Color represented in hue-saturation-value color space.
Definition: color.h:82
Pair of control points for a cubic bezier curve where the start is (0,0) and end is (1,...
Definition: keyframe_fade.h:61
point_t p1
First control point, from (0,0).
Definition: keyframe_fade.h:62
point_t p2
Second control point, to (1,1).
Definition: keyframe_fade.h:63
Fade keyframe.
Definition: keyframe_fade.h:70
uint8_t pair_index
Index of the first color of the currently transitioning pair.
Definition: keyframe_fade.h:89
float period
Number of seconds to fade over; max of 60 seconds.
Definition: keyframe_fade.h:76
timestep_t pair_period
The period to transition between each pair of colors.
Definition: keyframe_fade.h:87
fade_type_t fade_type
The type of transition to perform.
Definition: keyframe_fade.h:77
fade_axis_t fade_axis
Which axis of the colors need to be faded.
Definition: keyframe_fade.h:86
framerate_t framerate
Framerate currently being used.
Definition: keyframe_fade.h:91
cubic_bezier_t curve
The cubic bezier curve points for non-step transitions.
Definition: keyframe_fade.h:78
bool push_current
Push the current color to be the first.
Definition: keyframe_fade.h:79
keyframe_base_t base
Keyframe base; MUST be the first entry in the struct.
Definition: keyframe_fade.h:72
uint8_t colors_len
Number of colors provided.
Definition: keyframe_fade.h:80
point_t curr_b_info
The current bezier point to render.
Definition: keyframe_fade.h:90
timestep_t finish_time
Total number of frames for this keyframe at the current framerate.
Definition: keyframe_fade.h:88
Single point on a cartesian plane.
Definition: keyframe_fade.h:52
float y
Y-coordinate of the point.
Definition: keyframe_fade.h:54
float x
X-coordinate of the point.
Definition: keyframe_fade.h:53