summaryrefslogtreecommitdiff
path: root/Animation.h
blob: 6cebdb09eed453404198a20dff0ce7d2bde0312f (plain) (blame)
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
#ifndef _ANIMATION
#define _ANIMATION

#include "RGBImage.h"

struct AnimationEventNode;
typedef struct AnimationEventNode AnimationEventNode;

typedef struct Animation {
	u32 width;
	u32 height;
	u32 frameCount;
	u32 duplicateFrames;

	RGBImage frameBuffer;
	AnimationEventNode* events;
} Animation;

typedef struct PixelRendererParams {
	struct Frames {
		u32 current;
		u32 start;
		u32 end;
	} frame;

	ARGB pixel;

	i32 row;
	i32 col;

	void* priv;
} PixelRendererParams;

typedef ARGB (*PixelRenderer)(const Animation* anim, PixelRendererParams params);

AnimationEventNode* AnimationEventNode_new(u32 startFrame, u32 endFrame, PixelRenderer renderCallback, void* privateData);
Animation Animation_new(u32 width, u32 height, u32 frameCount);
void Animation_free(Animation anim);
void Animation_delete(Animation* anim);

void Animation_pushEvent(Animation* anim, u32 startFrame, u32 endFrame, PixelRenderer renderer, void* privateData);
void Animation_render(Animation* anim);

#endif /* _ANIMATION */