CanvasProgram

Trait CanvasProgram 

Source
pub trait CanvasProgram:
    Debug
    + Send
    + 'static {
    // Required method
    fn draw(&self, pixmap: &mut Pixmap);

    // Provided method
    fn need_redraw(&mut self) -> bool { ... }
}
Available on crate features resvg or tiny-skia only.
Expand description

Draws to a Canvas’s Pixmap

Note: the value is sometimes moved between threads, hence Send bound. If the type is large it should be boxed.

Required Methods§

Source

fn draw(&self, pixmap: &mut Pixmap)

Draw image

This method should draw an image to the canvas. It is called when the pixmap is created and resized and when requested by Self::need_redraw.

Note that Layout::draw does not call this method, but instead draws from a copy of the pixmap (updated each time this method completes).

Provided Methods§

Source

fn need_redraw(&mut self) -> bool

This method is called each time a frame is drawn. Note that since redrawing is async and non-blocking, the result is expected to be at least one frame late.

The default implementation returns false.

Implementors§