egui: give 20% margin from each side when zooming to fit

This commit is contained in:
Mikolaj Wielgus 2024-09-15 12:22:37 +02:00
parent a31bb43791
commit 92f82ff332
1 changed files with 2 additions and 2 deletions

View File

@ -299,9 +299,9 @@ impl Viewport {
if root_bbox_width / root_bbox_height
>= (viewport_rect.width() as f64) / (viewport_rect.height() as f64)
{
self.transform.scaling = viewport_rect.width() / root_bbox_width as f32;
self.transform.scaling = 0.8 * viewport_rect.width() / root_bbox_width as f32;
} else {
self.transform.scaling = viewport_rect.height() / root_bbox_height as f32;
self.transform.scaling = 0.8 * viewport_rect.height() / root_bbox_height as f32;
}
self.transform.translation = egui::Vec2::new(