Switched to an exponential function for cursor trail animation

macos-click-through
Jon Valdés 5 years ago
parent 4ea5e31f13
commit 5c8b1de97a

@ -47,6 +47,24 @@ pub fn ease_in_out_cubic(t: f32) -> f32 {
} }
} }
#[allow(dead_code)]
pub fn ease_in_expo(t: f32) -> f32 {
if t == 0.0 {
0.0
} else {
2.0f32.powf(10.0 * (t - 1.0))
}
}
#[allow(dead_code)]
pub fn ease_out_expo(t: f32) -> f32 {
if t == 1.0 {
1.0
} else {
1.0 - 2.0f32.powf(-10.0 * t)
}
}
pub fn lerp(start: f32, end: f32, t: f32) -> f32 { pub fn lerp(start: f32, end: f32, t: f32) -> f32 {
start + (end - start) * t start + (end - start) * t
} }

@ -280,7 +280,6 @@ impl CursorVfx for ParticleTrail {
canvas.draw_rect(&rect, &paint); canvas.draw_rect(&rect, &paint);
} }
} }
//canvas.draw_rect(&rect, &paint);
}); });
} }
} }

@ -180,7 +180,7 @@ impl Corner {
let direction_alignment = travel_direction.dot(corner_direction); let direction_alignment = travel_direction.dot(corner_direction);
self.current_position = self.current_position =
ease_point(ease_out_cubic, self.start_position, corner_destination, self.t); ease_point(ease_out_expo, self.start_position, corner_destination, self.t);
if self.t == 1.0 { if self.t == 1.0 {
// We are at destination, move t out of 0-1 range to stop the animation // We are at destination, move t out of 0-1 range to stop the animation

Loading…
Cancel
Save