mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
Fix sometimes blurry SVGs (#7071)
* Closes https://github.com/emilk/egui/issues/3501 The problem occurs when you want to render the same SVG at different scales, either at the same time in different parts of your UI, or at two different times (e.g. the DPI changes). The solution is to use the `SizeHint` as part of the key. However, when you have an SVG in a resizable container, that can lead to hundreds of versions of the same SVG. So new eviction code is added to handle this case.
This commit is contained in:
@@ -27,6 +27,15 @@ impl crate::View for SvgTest {
|
||||
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||
let Self { color } = self;
|
||||
ui.color_edit_button_srgba(color);
|
||||
ui.add(egui::Image::new(egui::include_image!("../../../data/peace.svg")).tint(*color));
|
||||
let img_src = egui::include_image!("../../../data/peace.svg");
|
||||
|
||||
// First paint a small version…
|
||||
ui.add_sized(
|
||||
egui::Vec2 { x: 20.0, y: 20.0 },
|
||||
egui::Image::new(img_src.clone()).tint(*color),
|
||||
);
|
||||
|
||||
// …then a big one, to make sure they are both crisp
|
||||
ui.add(egui::Image::new(img_src).tint(*color));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user