aboutsummaryrefslogtreecommitdiff
path: root/src/animate.h
blob: d153cda5d3fe10d3e6e00ed4e9df164d87a7e335 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef COMET_ANIMATE_H
#define COMET_ANIMATE_H

#include <glib.h>

#include "draw.h"

typedef struct Animation Animation;
typedef struct State State;

typedef bool (* LayoutFunc)(Animation *anim, Layout *layout);
typedef bool (* DrawFunc)(Animation *anim, Layout *layout, cairo_t *cr);

struct Animation {
    enum {
        ANIM_SHINE,
        ANIM_PULSE,
        ANIM_GROUP_SHRINK,
        //ANIM_GROUP_GROW,
    } type;
    gint64 start;
    gint64 duration;
    LayoutFunc layout_func;
    // NOTE: These should not change the layout width
    DrawFunc before_func;
    DrawFunc after_func;
};

double clamp(double x, double min, double max);

double smoothstep(double x, double edge0, double edge1);

double quadratic_bezier(double x, double a, double b, double c);

double cubic_bezier(double x, double a, double b, double c, double d);

Animation *animation_shine_create(gint64 duration);

Animation *animation_pulse_create(gint64 duration);

Animation *animation_group_shrink_create(gint64 duration);

void animation_destroy(Animation *anim);

#endif

// vim: ts=4 sw=4 et