#canvas #graphics

canvas-display

Wasm32 implementation for embedded-graphics https://github.com/jamwaffles/embedded-graphics DrawTarget. It is based on a HTML canvas.

3 releases

0.1.2 Sep 18, 2020
0.1.1 May 29, 2020
0.1.0 May 29, 2020

#737 in WebAssembly

MIT license

27KB
249 lines

canvas-display

MIT licensed crates.io docs.rs

Wasm32 implementation for embedded-graphics https://github.com/jamwaffles/embedded-graphics DrawTarget. It is based on a HTML canvas.

canvas-display

Usage

To include canvas-display in your project, add this dependency line to your Cargo.toml file:

canvas-display = "0.1.2"

To enable offscreen rendering, the crate provides a offscreen feature (no default feature). With this feature you have to call the flip method on CanvasDisplay after rendering.

Run examples

Requirements

Rust

canvas-display requires Rust 1.30 or newer.

wasm-pack

wasm-pack is required for building Rust-generated WebAssembly. Install it from https://rustwasm.github.io/wasm-pack/installer/.

npm

npm is a JavaScript package manger and is used to install and run a JavaScript bundler and development server. You could install npm from https://www.npmjs.com/get-npm.

For the examples we uses the latest version of npm. You could install it with this command:

npm install npm@latest -g

Run example

Navigate to directory of the example and run:

npm install

To serve the example locally run:

npm run serve

Navigate your Web browser to http://localhost:8080/

Build and run documentation

You can build and view the latest documentation by executing the following command:

cargo doc --no-deps --open

Dependencies

~12MB
~203K SLoC