Skip to main content

wisp_storybook/stories/
s_text.rs

1//! Story: bitmap text rendering — Hello world + multi-line keyboard chip (M0.15).
2
3use glam::Vec2;
4use wisp::application::Application;
5use wisp::{Color, Font, Stage, Text};
6
7use crate::story::Story;
8
9pub fn story() -> Story {
10    Story {
11        id: "text-bitmap",
12        category: "Scene Graph",
13        title: "Bitmap text",
14        milestone: "M0.15",
15        writeup: include_str!("writeups/text.md"),
16        build,
17        tick: None,
18    }
19}
20
21fn build(app: &Application, stage: &mut Stage) {
22    let font = Font::bitmap_8x8(app);
23
24    // Big "Hello, world!" near the top.
25    let mut hello = Text::new(font.clone(), "Hello, world!")
26        .with_cell_size(0.025)
27        .with_color(Color::rgba_u8(240, 240, 250, 255));
28    hello.container.transform.position = Vec2::new(-0.7, 0.3);
29    let _ = stage.add_child(stage.root(), hello);
30
31    // Multi-line keyboard chip below.
32    let mut chip = Text::new(font, "Cmd+Shift+.\nQuick action")
33        .with_cell_size(0.018)
34        .with_color(Color::rgba_u8(160, 220, 255, 255));
35    chip.container.transform.position = Vec2::new(-0.45, -0.1);
36    let _ = stage.add_child(stage.root(), chip);
37}