[][src]Struct canvas_display::CanvasDisplay

pub struct CanvasDisplay { /* fields omitted */ }

This display is based on a HTML Canvas and is used as draw target for the embedded graphics crate.

Example

use canvas_display::prelude::*;
use embedded_graphics::{
    image::{Image, ImageRaw, ImageRawLE},
    pixelcolor::Rgb565,
    prelude::*,
    primitives::rectangle::Rectangle,
    style::PrimitiveStyleBuilder,
    };

let mut display = CanvasDisplay::new(160, 128, "canvas").unwrap();

let style = PrimitiveStyleBuilder::new().fill_color(Rgb565::BLACK).build();
let black_backdrop = Rectangle::new(Point::new(0, 0), Point::new(160, 128)).into_styled(style);
black_backdrop.draw(&mut display).unwrap();

// draw ferris
let image_raw: ImageRawLE<Rgb565> = ImageRaw::new(include_bytes!("../../../assets/ferris.raw"), 86, 64);
let image: Image<_, Rgb565> = Image::new(&image_raw, Point::new(34, 8));
image.draw(&mut display).unwrap();

Implementations

impl CanvasDisplay[src]

pub fn new(width: u32, height: u32, canvas: &str) -> Result<Self, String>[src]

Creates a new canvas display with the given. The canvas get the given with and height and will be referenced by the given canvas css id. If no canvas with this id exists a canvas will be created.

pub fn context(&self) -> &CanvasRenderingContext2d[src]

Gets the current rendering context 2d.

Trait Implementations

impl Clone for CanvasDisplay[src]

impl Debug for CanvasDisplay[src]

impl DrawTarget<Rgb565> for CanvasDisplay[src]

type Error = String

Error type to return when a drawing operation fails. Read more

impl PartialEq<CanvasDisplay> for CanvasDisplay[src]

impl StructuralPartialEq for CanvasDisplay[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.