bbx_draw/sketch/traits.rs
1//! Sketch trait definition.
2
3use nannou::{App, Frame, event::Update};
4
5/// Trait for nannou sketches that can be discovered and run.
6///
7/// Implementing this trait allows sketches to be registered and managed
8/// by the `Sketchbook`.
9pub trait Sketch: Sized {
10 /// The display name of this sketch.
11 fn name(&self) -> &str;
12
13 /// A brief description of what this sketch visualizes.
14 fn description(&self) -> &str;
15
16 /// Create the initial model/state for this sketch.
17 fn model(app: &App) -> Self;
18
19 /// Update the sketch state each frame.
20 fn update(&mut self, app: &App, update: Update);
21
22 /// Draw the sketch to the frame.
23 fn view(&self, app: &App, frame: Frame);
24}