use crate::egui::text::LayoutJob; use crate::egui::Ui; use crate::slide::Slide; use eframe::egui::style::Margin; use eframe::egui::{FontFamily, FontId, Frame, Sense, Shape, Stroke, TextFormat}; use eframe::epaint::TextShape; #[derive(Default)] pub struct Conclusion {} impl Slide for Conclusion { fn show(&mut self, ui: &mut Ui) { ui.style_mut().debug.debug_on_hover = true; ui.style_mut().debug.show_expand_height = true; ui.style_mut().debug.show_resize = true; ui.style_mut().debug.show_expand_width = true; Frame::none().margin(Margin::same(20.0)).show(ui, |ui| { ui.heading("Conclusion"); ui.add_space(8.0); let font_size = 30.0; let color = ui.style().visuals.widgets.noninteractive.fg_stroke.color; let mut job = LayoutJob::default(); job.append( "In the spirit of generative art, ", 0.0, TextFormat { font_id: FontId::new(font_size, FontFamily::Proportional), color, ..Default::default() }, ); job.append( "this entire cartoon was rendered by code", 0.0, TextFormat { font_id: FontId::new(font_size, FontFamily::Monospace), color, underline: Stroke::new(1.5, color), ..Default::default() }, ); job.append( "!", 0.0, TextFormat { font_id: FontId::new(font_size, FontFamily::Proportional), color, ..Default::default() }, ); let galley = ui.fonts().layout_job(job); let (rect, _) = ui.allocate_exact_size(galley.size(), Sense::hover()); ui.painter() .add(Shape::Text(TextShape::new(rect.left_top(), galley))); }); } }