diff options
| author | Syndamia <kamen@syndamia.com> | 2026-03-28 22:14:32 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2026-03-28 22:14:32 +0200 |
| commit | 1cc8f72fb1c44e203a324e274038c2883c351fbb (patch) | |
| tree | bb3f63143fc643fa9d35bcba6566a0d6ef445cab /AnimationRender/AnimationRender.c | |
| parent | 6a63e2c0e1f37c502501e1b611e8dc289476c1f2 (diff) | |
| download | ppm_graphics-1cc8f72fb1c44e203a324e274038c2883c351fbb.tar ppm_graphics-1cc8f72fb1c44e203a324e274038c2883c351fbb.tar.gz ppm_graphics-1cc8f72fb1c44e203a324e274038c2883c351fbb.zip | |
feat: Add animation capabilities with linear interpolation
Diffstat (limited to 'AnimationRender/AnimationRender.c')
| -rw-r--r-- | AnimationRender/AnimationRender.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/AnimationRender/AnimationRender.c b/AnimationRender/AnimationRender.c new file mode 100644 index 0000000..8974ba3 --- /dev/null +++ b/AnimationRender/AnimationRender.c @@ -0,0 +1,26 @@ +#include "AnimationRender.h" +#include "FrameCallback.h" + +void RenderAnimation(u32 width, u32 height, u32 totalFrames, const FrameCallback** callbacks, usize sizeCallbacks) { + RGBImage frameBuffer = RGBImage_new(width, height); + + struct FrameContext fc; + fc.startFrame = 0; + fc.endFrame = totalFrames; + fc.frameBuffer = frameBuffer; + + for (u32 f = 0; f < totalFrames; ++f) { + fc.frame = f; + for (usize i = 0; i < sizeCallbacks; ++i) { + // Soft context reset + if (callbacks[i] == NULL) { + fc.startFrame = 0; + fc.endFrame = totalFrames; + } + else + callbacks[i]->callback(callbacks[i]->callback_self, &fc); + } + } + + RGBImage_delete(&frameBuffer); +} |
