This crate acts as a drop-in replacement for the nannou crate that provides an additional Model
trait to allow persisting state easier.
In summary, the following code (with the original nannou crate):
fn main() {
nannou::app(model)
.update(update)
.simple_window(view);
}
Is equivalent to (with this crate):
use nannou::prelude::*;
struct App {
// state
}
impl nannou::Model for App {
fn init(&mut self, app: &nannou::App) {
// model init function
}
fn update(&mut self, app: &nannou::App, update: Update) {
// update function
}
fn view(&self, app: &nannou::App, frame: Frame) {
// view function
}
}
fn main() {
nannou::run(App { /* initial state */ }, |builder| builder);
}
where the original init/update/view methods can be inlined to allow access to self
.
See examples/basic.rs for a runnable demo.
nannou = { package = "nannou_oop", git = "https://github.com/Nigecat/nannou-oop" }