mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Add Rect::lerp
This commit is contained in:
@@ -359,6 +359,15 @@ impl Rect {
|
|||||||
inside_dist + outside_dist
|
inside_dist + outside_dist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Linearly interpolate so that `[0, 0]` is [`Self::min`] and
|
||||||
|
/// `[1, 1]` is [`Self::max`].
|
||||||
|
pub fn lerp(&self, t: Vec2) -> Pos2 {
|
||||||
|
Pos2 {
|
||||||
|
x: lerp(self.min.x..=self.max.x, t.x),
|
||||||
|
y: lerp(self.min.y..=self.max.y, t.y),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn x_range(&self) -> RangeInclusive<f32> {
|
pub fn x_range(&self) -> RangeInclusive<f32> {
|
||||||
self.min.x..=self.max.x
|
self.min.x..=self.max.x
|
||||||
|
|||||||
Reference in New Issue
Block a user