add AnimationHelper::scaled_rect

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-08-28 16:26:36 -04:00
parent e9ca793509
commit d448caa369

View File

@@ -1,4 +1,4 @@
use egui::{Pos2, Rect, Response, Sense}; use egui::{vec2, Pos2, Rect, Response, Sense};
pub fn hover_expand( pub fn hover_expand(
ui: &mut egui::Ui, ui: &mut egui::Ui,
@@ -116,6 +116,16 @@ impl AnimationHelper {
self.rect self.rect
} }
pub fn scaled_rect(&self) -> egui::Rect {
let min_height = self.rect.height() * (1.0 / self.expansion_multiple);
let min_width = self.rect.width() * (1.0 / self.expansion_multiple);
egui::Rect::from_center_size(
self.center,
vec2(self.scale_1d_pos(min_width), self.scale_1d_pos(min_height)),
)
}
pub fn center(&self) -> Pos2 { pub fn center(&self) -> Pos2 {
self.rect.center() self.rect.center()
} }