[−][src]Struct pixel_canvas::canvas::Canvas
A Canvas manages a window and event loop, handing
the current state to the renderer, and presenting its image on the screen.
Implementations
impl Canvas<()>[src]
pub fn new(width: usize, height: usize) -> Canvas<()>[src]
Create a new canvas with a given virtual window dimensions.
impl<State, Handler> Canvas<State, Handler> where
Handler: FnMut(&CanvasInfo, &mut State, &Event<'_, ()>) -> bool + 'static,
State: 'static, [src]
Handler: FnMut(&CanvasInfo, &mut State, &Event<'_, ()>) -> bool + 'static,
State: 'static,
pub fn state<NewState>(
self,
state: NewState
) -> Canvas<NewState, EventHandler<NewState>>[src]
self,
state: NewState
) -> Canvas<NewState, EventHandler<NewState>>
Set the attached state.
Attaching a new state object will reset the input handler.
pub fn title(self, text: impl Into<String>) -> Self[src]
Set the title on the canvas window.
pub fn hidpi(self, enabled: bool) -> Self[src]
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.
pub fn show_ms(self, enabled: bool) -> Self[src]
Whether to show a frame duration in the title bar.
Defaults to false.
pub fn render_on_change(self, enabled: bool) -> Self[src]
Whether to render a new frame only on state changes.
Defaults to false, which means it will render at a fixed framerate.
pub fn input<NewHandler>(
self,
callback: NewHandler
) -> Canvas<State, NewHandler> where
NewHandler: FnMut(&CanvasInfo, &mut State, &Event<'_, ()>) -> bool + 'static, [src]
self,
callback: NewHandler
) -> Canvas<State, NewHandler> where
NewHandler: FnMut(&CanvasInfo, &mut State, &Event<'_, ()>) -> bool + 'static,
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.
pub fn render(self, callback: impl FnMut(&mut State, &mut Image) + 'static)[src]
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
impl<State, Handler> RefUnwindSafe for Canvas<State, Handler> where
Handler: RefUnwindSafe,
State: RefUnwindSafe,
Handler: RefUnwindSafe,
State: RefUnwindSafe,
impl<State, Handler> Send for Canvas<State, Handler> where
Handler: Send,
State: Send,
Handler: Send,
State: Send,
impl<State, Handler> Sync for Canvas<State, Handler> where
Handler: Sync,
State: Sync,
Handler: Sync,
State: Sync,
impl<State, Handler> Unpin for Canvas<State, Handler> where
Handler: Unpin,
State: Unpin,
Handler: Unpin,
State: Unpin,
impl<State, Handler> UnwindSafe for Canvas<State, Handler> where
Handler: UnwindSafe,
State: UnwindSafe,
Handler: UnwindSafe,
State: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,