pub struct Canvas<State, Handler = EventHandler<State>> { /* private fields */ }
Expand description

A Canvas manages a window and event loop, handing the current state to the renderer, and presenting its image on the screen.

Implementations

Create a new canvas with a given virtual window dimensions.

Set the attached state.

Attaching a new state object will reset the input handler.

Set the title on the canvas window.

Toggle hidpi render.

Defaults to false. If you have a hidpi monitor, this will cause the image to be larger than the dimensions you specified when creating the canvas.

Whether to show a frame duration in the title bar.

Defaults to false.

Whether to render a new frame only on state changes.

Defaults to false, which means it will render at a fixed framerate.

Attach an input handler.

Your input handler must be compatible with any state that you’ve set previously. Your event handler will be called for each event with the canvas information, the current state, and the inciting event.

Provide a rendering callback.

The canvas will call your rendering callback on demant, with the current state and a reference to the image. Depending on settings, this will either be called at 60fps, or only called when state changes. See render_on_change.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.