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

Smooth preview

This commit is contained in:
Emil Ernerfeldt
2023-04-25 12:25:17 +02:00
parent e5d0cf68d6
commit 1d0509de23
2 changed files with 61 additions and 4 deletions

View File

@@ -361,13 +361,28 @@ impl Rect {
/// Linearly interpolate so that `[0, 0]` is [`Self::min`] and
/// `[1, 1]` is [`Self::max`].
#[deprecated = "Use `lerp_inside` instead"]
pub fn lerp(&self, t: Vec2) -> Pos2 {
self.lerp_inside(t)
}
/// Linearly interpolate so that `[0, 0]` is [`Self::min`] and
/// `[1, 1]` is [`Self::max`].
pub fn lerp_inside(&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),
}
}
/// Linearly self towards other rect.
pub fn lerp_towards(&self, other: &Rect, t: f32) -> Self {
Self {
min: self.min.lerp(other.min, t),
max: self.max.lerp(other.max, t),
}
}
#[inline(always)]
pub fn x_range(&self) -> RangeInclusive<f32> {
self.min.x..=self.max.x