wisp_storybook/stories/
s_graphics_arc.rs1use std::f32::consts::{FRAC_PI_2, FRAC_PI_4, PI, TAU};
12
13use glam::Vec2;
14use wisp::application::Application;
15use wisp::{Color, Fill, Graphics, Stage};
16
17use crate::story::Story;
18
19pub fn story() -> Story {
20 Story {
21 id: "graphics-arc",
22 category: "Graphics",
23 title: "Arc + annular sector",
24 milestone: "M-VEC.20",
25 writeup: include_str!("writeups/graphics_arc.md"),
26 build,
27 tick: None,
28 }
29}
30
31fn build(_app: &Application, stage: &mut Stage) {
32 let mut g = Graphics::new();
33
34 let col_x = [-0.66, 0.0, 0.66];
36 let row_y = [0.5, -0.5];
37 let radius = 0.22;
38
39 g.fill(Fill::Solid(Color::rgba_u8(80, 200, 255, 255)));
41 g.draw_annular_sector(Vec2::new(col_x[0], row_y[0]), 0.0, radius, 0.0, TAU);
42
43 g.fill(Fill::Solid(Color::rgba_u8(255, 200, 80, 255)));
45 g.draw_annular_sector(Vec2::new(col_x[1], row_y[0]), 0.0, radius, 0.0, FRAC_PI_2);
46
47 g.fill(Fill::Solid(Color::rgba_u8(160, 100, 220, 255)));
49 g.draw_annular_sector(Vec2::new(col_x[2], row_y[0]), 0.12, radius, 0.0, TAU);
50
51 g.fill(Fill::Solid(Color::rgba_u8(120, 220, 140, 255)));
53 g.draw_annular_sector(
54 Vec2::new(col_x[0], row_y[1]),
55 0.12,
56 radius,
57 FRAC_PI_4,
58 FRAC_PI_4 + TAU * 0.75,
59 );
60
61 g.fill(Fill::Solid(Color::rgba_u8(255, 100, 80, 255)));
63 g.draw_arc(
64 Vec2::new(col_x[1], row_y[1]),
65 radius,
66 -FRAC_PI_4,
67 FRAC_PI_4,
68 0.025,
69 );
70
71 g.fill(Fill::Solid(Color::rgba_u8(80, 220, 200, 255)));
73 g.draw_arc(Vec2::new(col_x[2], row_y[1]), radius, PI, TAU, 0.05);
74
75 let _ = stage.add_child(stage.root(), g);
76}