Skip to main content

Draw

Trait Draw 

Source
pub trait Draw: 'static {
    // Required method
    fn draw(&self, ctx: &mut DrawCtx);

    // Provided method
    fn size(&self) -> (f64, f64) { ... }
}
Expand description

What a node of your own draws, in its own coordinates (origin at the center of its box, y down).

draw must be a function of the node’s values and ctx.time(): the frame is painted again on seek, and check reports a node whose two paints of one frame differ. Use ctx.rng(seed) for randomness.

Required Methods§

Source

fn draw(&self, ctx: &mut DrawCtx)

Paints the node with ctx.line, ctx.circle, ctx.rect, ctx.arc and ctx.path.

Provided Methods§

Source

fn size(&self) -> (f64, f64)

The node’s box: what layout, Camera::fit and check use. The default is 100 by 100.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§