| 1 |
# Paint Example |
| 2 |
|
| 3 |
[View full source code][code] or [view the compiled example online][online] |
| 4 |
|
| 5 |
[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/paint/ |
| 6 |
[code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/paint |
| 7 |
|
| 8 |
A simple painting program. |
| 9 |
|
| 10 |
## `Cargo.toml` |
| 11 |
|
| 12 |
The `Cargo.toml` enables features necessary to work with the DOM, events and |
| 13 |
2D canvas. |
| 14 |
|
| 15 |
```toml |
| 16 |
{{#include ../../../examples/paint/Cargo.toml}} |
| 17 |
``` |
| 18 |
|
| 19 |
## `src/lib.rs` |
| 20 |
|
| 21 |
Creates the `<canvas>` element, applies a CSS style to it, adds it to the document, |
| 22 |
get a 2D rendering context and adds listeners for mouse events. |
| 23 |
|
| 24 |
```rust |
| 25 |
{{#include ../../../examples/paint/src/lib.rs}} |
| 26 |
``` |