Newer
Older
use crate::color::get_style_alpha;
use crate::component::code::Code;
use eframe::egui::{Color32, FontFamily, FontId, Frame, Sense, Shape, Stroke, TextFormat};
pub struct Conclusion {
fade_in: Option<f64>,
}
self.fade_in.get_or_insert(ui.ctx().input().time);
/*
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);
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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)));
let elapsed = (ui.ctx().input().time - self.fade_in.unwrap()) as f32;
ui.ctx().request_repaint();
Code {
name: "slides",
position: WindowPosition::FromCenter(Vec2::new(0.0, ui.available_height() * 0.08)),
size: Vec2::new(ui.available_width() * 0.95, ui.available_height() * 0.85),
scroll: Some((elapsed * 90.0 + 350.0).min(1065.0)),
background: Color32::TRANSPARENT,
alpha: get_style_alpha(ui.style()),
code: String::from(include_str!("../cartoon.rs")),
..Code::default()
}
.show(ui.ctx());