Crate sketchbook

Source
Expand description

Interactive visual applications in Rust.

use sketchbook::*;
use sketchbook::ream::Single;

#[apply(derive_sketch)]
#[sketch(
    env = minimal,
    aspects = (/* aspects go here */),
)]
struct App {
    #[page] page: minimal::Page,
}

impl Setup for App {
    fn setup(page: minimal::Page, _: ()) -> Self {
        Self { page }
    }
}

fn main() {
    Book::<Single<App>>::bind();
}

§Environments

CrateDescriptionStatus
sketchbook-wgpuDirectly uses winit and wgpu to run sketches.In Development
sketchbook-webRuns sketches in a web browser.Planned
sketchbook-avrRuns sketches on AVR micro-controllers (E.g. AVR based Arduinos)Planned

§Feature Flags

  • default — No features are enabled by default.

§Optional Components

§Aspects
  • aspect-update — Aspect that periodically updates a sketch.
  • aspect-keyboard — Aspect for keyboard input.
  • aspect-mouse — Aspect for mouse input.
  • aspect-draw — Aspect for drawing onto the environment’s page.
§Reams
  • ream-concurrent — Ream that runs multiple sketches without threads.
  • ream-parallel — Ream that runs multiple sketches on independant threads.
  • ream-single — Ream that runs a single sketch.
§Environments
  • env-aspect-test — Macro for generating environments to test aspects.
  • env-minimal — Minimal environment that implements no aspects.

§Optional Dependencies

  • std — Support for using the standard library.
  • alloc — Support for using allocation.
  • derive — Re-export macro_rules_attribute for better macro syntax.
  • color — Support for palette based colors.
  • serde — Support for serde.

Modules§

aspects
Built-in aspects of environments.
compose
Traits for generic composition.
minimalenv-minimal
Minimal environment for use in examples and tests.
ream
Built-in reams to run sketches.

Macros§

compose
Create type composed of other types.
derive_sketch
Implements the Sketch trait for a struct.
env_for_aspectenv-aspect-test
Macro to create environment for testing a single aspect.

Structs§

Book
A set of sketches.
Pages
Pages of a book.
Point2
2D point (x, y)
Size2
2D size (width, height)
Vector2
2D vector (x, y)

Enums§

Status
Status flag

Traits§

Environment
Environment for sketches to run in and interact with.
Mill
Factory for creating pages from an environment.
Page
Trait for environment page.
Real
Trait for real numbers.
Setup
Trait for setting up a sketch given some input.
Sketch
Base trait for all sketches.
ToReal
Convert to real number.

Type Aliases§

EventOf
Helper to get Event of type implementing the Environment trait.
MillOf
Helper to get Mill of type implementing the Environment trait.
PageOf
Helper to get Page of type implementing the Environment trait.

Attribute Macros§

apply
Re-export of macro_rules_attribute’s apply macro.