forked from jirutka/swaylock-effects
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfade.c
More file actions
26 lines (21 loc) · 619 Bytes
/
fade.c
File metadata and controls
26 lines (21 loc) · 619 Bytes
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
#include "fade.h"
#include "swaylock.h"
#include <stdlib.h>
void fade_update(struct swaylock_fade *fade, uint32_t time) {
if (fade->current_time >= fade->target_time) {
return;
}
double delta = 0;
if (fade->old_time != 0) {
delta = time - fade->old_time;
}
fade->old_time = time;
fade->current_time += delta;
if (fade->current_time > fade->target_time) {
fade->current_time = fade->target_time;
}
fade->alpha = (double)fade->current_time / (double)fade->target_time;
}
bool fade_is_complete(struct swaylock_fade *fade) {
return fade->target_time == 0 || fade->current_time >= fade->target_time;
}