Trait Sketch

Source
pub trait Sketch: Sized {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn model(app: &App) -> Self;
    fn update(&mut self, app: &App, update: Update);
    fn view(&self, app: &App, frame: Frame<'_>);
}
Expand description

Trait for nannou sketches that can be discovered and run.

Implementing this trait allows sketches to be registered and managed by the Sketchbook.

Required Methods§

Source

fn name(&self) -> &str

The display name of this sketch.

Source

fn description(&self) -> &str

A brief description of what this sketch visualizes.

Source

fn model(app: &App) -> Self

Create the initial model/state for this sketch.

Source

fn update(&mut self, app: &App, update: Update)

Update the sketch state each frame.

Source

fn view(&self, app: &App, frame: Frame<'_>)

Draw the sketch to the frame.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§