wisp_storybook/stories/
s_graphics_gradients.rs1use glam::Vec2;
4use wisp::application::Application;
5use wisp::math::Rect;
6use wisp::{Color, Fill, Graphics, Stage};
7
8use crate::story::Story;
9
10pub fn story() -> Story {
11 Story {
12 id: "graphics-gradients",
13 category: "Graphics",
14 title: "Gradient fills",
15 milestone: "M0.14",
16 writeup: include_str!("writeups/graphics_gradients.md"),
17 build,
18 tick: None,
19 }
20}
21
22fn build(_app: &Application, stage: &mut Stage) {
23 let mut g = Graphics::new();
24
25 g.fill(Fill::LinearGradient {
27 start: Vec2::new(0.0, 0.4),
28 end: Vec2::new(0.0, -0.4),
29 color_a: Color::rgba_u8(255, 110, 80, 255),
30 color_b: Color::rgba_u8(80, 110, 255, 255),
31 });
32 g.draw_rounded_rect(Rect::new(-0.85, -0.4, 0.7, 0.8), 0.08);
33
34 g.fill(Fill::RadialGradient {
36 center: Vec2::ZERO,
37 radius: 0.4,
38 color_a: Color::rgba_u8(255, 240, 200, 255),
39 color_b: Color::rgba_u8(40, 30, 80, 255),
40 });
41 g.draw_ellipse(Vec2::new(0.5, 0.0), Vec2::new(0.4, 0.4));
42
43 let _ = stage.add_child(stage.root(), g);
44}