feat: add flash countdown and responsive photobooth overlays
This commit is contained in:
@@ -185,6 +185,11 @@ impl Tracker {
|
||||
Some((self.palm?, (elapsed - 1.0).clamp(0.0, 1.0)))
|
||||
}
|
||||
|
||||
pub fn complete(&self, now: Instant) -> bool {
|
||||
self.visible(now)
|
||||
.is_some_and(|(_, progress)| progress >= 1.0)
|
||||
}
|
||||
|
||||
pub fn has_palm(&self, now: Instant) -> bool {
|
||||
self.last_seen
|
||||
.is_some_and(|seen| now.duration_since(seen) < STALE_AFTER)
|
||||
@@ -271,6 +276,7 @@ mod tests {
|
||||
for ms in [0, 250, 500, 750, 1000, 1250, 1500, 1750, 2000] {
|
||||
let now = start + Duration::from_millis(ms);
|
||||
tracker.update(palm(100.0), now);
|
||||
assert_eq!(tracker.complete(now), ms >= 2000);
|
||||
assert_eq!(
|
||||
tracker.visible(now).unwrap().1,
|
||||
((ms as f64 / 1000.0) - 1.0).clamp(0.0, 1.0)
|
||||
|
||||
Reference in New Issue
Block a user