Skip to main content

pulsating_between

Function pulsating_between 

Source
pub fn pulsating_between(min: f32, max: f32) -> impl Fn(f32) -> f32
Expand description

Breathes between min and max, for idle indicators.

Over one cycle the value is at max near a quarter of the way through, at min near three quarters, and at the midpoint at the start, the middle and the end. Use it with Animation::repeat_synced so that several indicators pulse together. The result is a closure, so call it as pulsating_between(min, max).

ยงExamples

use gpui::pulsating_between;

let breathe = pulsating_between(0.3, 1.0);
assert!((breathe(0.25) - 1.0).abs() < 1e-6);
assert!((breathe(0.75) - 0.3).abs() < 1e-6);
assert!((breathe(0.0) - 0.65).abs() < 1e-6);