wisp_storybook/stories/
s_cursor_overlay.rs1use wisp::application::Application;
14use wisp::math::Rect;
15use wisp::{Color, Fill, Graphics, Stage};
16
17pub fn story() -> crate::story::Story {
18 crate::story::Story {
19 id: "editor-cursor-overlay",
20 category: "Editor",
21 title: "Cursor overlay — pointer + click ripple",
22 milestone: "ED.19",
23 writeup: include_str!("writeups/editor_cursor.md"),
24 build,
25 tick: None,
26 }
27}
28
29fn build(_app: &Application, stage: &mut Stage) {
30 let mut screen = Graphics::new();
33 screen.fill(Fill::LinearGradient {
34 start: glam::Vec2::new(0.0, 1.0),
35 end: glam::Vec2::new(0.0, -1.0),
36 color_a: Color::rgb_u8(244, 247, 250),
37 color_b: Color::rgb_u8(206, 216, 228),
38 });
39 screen.draw_rect(Rect::new(-1.0, -1.0, 2.0, 2.0));
40 let _ = stage.add_child(stage.root(), screen);
41
42 let point = glam::Vec2::new(0.08, 0.04);
45 let half = 0.13;
46 let mut overlay = Graphics::new();
47 overlay.fill(Fill::Solid(Color::rgba(0.25, 0.5, 0.95, 0.18)));
49 overlay.draw_ellipse(point, glam::Vec2::splat(half * 2.6));
50 overlay.fill(Fill::Solid(Color::rgba(0.25, 0.5, 0.95, 0.30)));
51 overlay.draw_ellipse(point, glam::Vec2::splat(half * 1.6));
52 let pointer = |overlay: &mut Graphics, s: f32, color: Color| {
55 let scale = half * s;
56 let p = |x: f32, y: f32| point + glam::Vec2::new(x, y) * scale;
57 overlay.fill(Fill::Solid(color));
58 overlay.draw_polygon(&[p(0.0, 0.0), p(0.0, -1.5), p(0.45, -1.75), p(1.05, -0.95)]);
59 };
60 pointer(&mut overlay, 1.25, Color::rgb_u8(20, 20, 20));
61 pointer(&mut overlay, 1.0, Color::WHITE);
62 let _ = stage.add_child(stage.root(), overlay);
63}