pub trait Generator: Send {
// Required methods
fn meta(&self) -> &'static Meta;
fn resize(&mut self, size: Size, ctx: &mut Ctx);
fn update(&mut self, dt: f64, ctx: &mut Ctx);
fn render(&self, canvas: &mut Canvas);
// Provided methods
fn prepare(&mut self) { ... }
fn caption(&self) -> Option<&'static str> { ... }
}Expand description
A scene (CORE-R14). Call protocol (CORE-R15), guaranteed by the runtime:
resize before the first update/render and on every size change;
render receives a cleared canvas of the last resized size.
Contract (GEN-R4..R10): never panic for any size >= 1x1, rebuild size-dependent
state in resize, use only ctx.rng and dt/ctx.time().
Required Methods§
fn meta(&self) -> &'static Meta
fn resize(&mut self, size: Size, ctx: &mut Ctx)
fn update(&mut self, dt: f64, ctx: &mut Ctx)
fn render(&self, canvas: &mut Canvas)
Provided Methods§
Sourcefn prepare(&mut self)
fn prepare(&mut self)
Called by Stage::render exactly once right before every render (CORE-R101):
the place to rasterise simulation state into the scene’s buffers once per drawn
frame rather than once per step (the runtime takes about two 60 Hz steps per
30 FPS frame; GEN-R20). Must not advance the simulation or draw from ctx.rng,
and must not allocate (GEN-R11). Default: nothing.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".