Moved easing functions into their own file

This commit is contained in:
Erik Reider 2024-01-26 19:46:13 +01:00
parent 8193bb6e4b
commit dec948dc80
4 changed files with 24 additions and 9 deletions

View file

@ -0,0 +1,10 @@
#ifndef ANIMATION_UTILS_H
#define ANIMATION_UTILS_H
double lerp (double a, double b, double t);
double ease_out_cubic (double t);
// TODO: Add more easing functions in the future like ease_in and ease_in_out, etc...
#endif

View file

@ -0,0 +1,12 @@
#include <math.h>
#include "sway/desktop/fx_renderer/animation_utils.h"
double lerp (double a, double b, double t) {
return a * (1.0 - t) + b * t;
}
double ease_out_cubic (double t) {
double p = t - 1;
return pow(p, 3) + 1;
}

View file

@ -19,6 +19,7 @@
#include "config.h"
#include "log.h"
#include "sway/config.h"
#include "sway/desktop/fx_renderer/animation_utils.h"
#include "sway/desktop/transaction.h"
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
@ -1108,15 +1109,6 @@ void handle_output_power_manager_set_mode(struct wl_listener *listener,
apply_output_config(oc, output);
}
static double lerp (double a, double b, double t) {
return a * (1.0 - t) + b * t;
}
static double ease_out_cubic (double t) {
double p = t - 1;
return pow(p, 3) + 1;
}
struct workspace_scroll workspace_scroll_get_default() {
return (struct workspace_scroll) {
.percent = 0,

View file

@ -20,6 +20,7 @@ sway_sources = files(
'desktop/fx_renderer/fx_stencilbuffer.c',
'desktop/fx_renderer/fx_texture.c',
'desktop/fx_renderer/matrix.c',
'desktop/fx_renderer/animation_utils.c',
'desktop/idle_inhibit_v1.c',
'desktop/layer_shell.c',
'desktop/output.c',