feat: Calculate animation curve by time points rather than passed frames

This commit is contained in:
DreamMaoMao
2025-11-04 11:31:04 +08:00
parent 70eb70ef0d
commit b39ab429f5
6 changed files with 76 additions and 84 deletions

View File

@@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "util.h"
@@ -80,3 +81,15 @@ int regex_match(const char *pattern, const char *str) {
void wl_list_append(struct wl_list *list, struct wl_list *object) {
wl_list_insert(list->prev, object);
}
unsigned int get_now_in_ms(void) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return timespec_to_ms(&now);
}
unsigned int timespec_to_ms(struct timespec *ts) {
return (unsigned int)ts->tv_sec * 1000 +
(unsigned int)ts->tv_nsec / 1000000;
}