Implement proper unit bezier easing function

Code based on WebKit
https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/graphics/UnitBezier.h
This commit is contained in:
Kovid Goyal
2024-07-17 10:06:18 +05:30
parent f090c9a895
commit fc13b06b35
8 changed files with 308 additions and 66 deletions

View File

@@ -9,15 +9,16 @@
#include <stddef.h>
#include <stdbool.h>
#include "monotonic.h"
typedef enum { EASING_STEP_START, EASING_STEP_END, EASING_STEP_NONE, EASING_STEP_BOTH } EasingStep;
#ifndef ANIMATION_INTERNAL_API
typedef struct {int x;} *Animation;
#endif
Animation* alloc_animation(void);
double apply_easing_curve(const Animation *a, double t /* must be between 0 and 1*/);
double apply_easing_curve(const Animation *a, double t /* must be between 0 and 1*/, monotonic_t duration);
bool animation_is_valid(const Animation *a);
void add_cubic_bezier_animation(Animation *a, double y_at_start, double y_at_end, double start, double p1, double p2, double end);
void add_linear_animation(Animation *a, double y_at_start, double y_at_end, size_t count, const double *params, const double *positions);
void add_cubic_bezier_animation(Animation *a, double y_at_start, double y_at_end, double p1_x, double p1_y, double p2_x, double p2_y);
void add_linear_animation(Animation *a, double y_at_start, double y_at_end, size_t count, const double *x, const double *y);
void add_steps_animation(Animation *a, double y_at_start, double y_at_end, size_t count, EasingStep step);
Animation* free_animation(Animation *a);