1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 22:30:03 -04:00

Add emath::Rangef and helpers for splitting a Rect (#2978)

* emath: add Rangef helper

* emath: Add Rect splitting helper

* Add helper for interpolating Pos2
This commit is contained in:
Emil Ernerfeldt
2023-05-08 12:20:26 +02:00
committed by GitHub
parent 3d6a15f442
commit faf31365d2
4 changed files with 166 additions and 2 deletions

View File

@@ -188,6 +188,14 @@ impl Pos2 {
y: self.y.clamp(min.y, max.y),
}
}
/// Linearly interpolate towards another point, so that `0.0 => self, 1.0 => other`.
pub fn lerp(&self, other: Pos2, t: f32) -> Pos2 {
Pos2 {
x: lerp(self.x..=other.x, t),
y: lerp(self.y..=other.y, t),
}
}
}
impl std::ops::Index<usize> for Pos2 {