Awesome
waPC + Mandelbrot example
Adaptation of https://www.assemblyscript.org/examples/mandelbrot.html for waPC.
Renders the Mandelbrot set to a canvas using 2048 discrete color values computed on the JS side.
Contents:
index.html
- contains the canvasjs/wapc.js
- loads waPC modules in the browser/JavaScriptjs/mandelbrot.js
- performs the rendering on the JS sidewasm/mandelbrot-as.wasm
- Compiled AssemblyScript module that computes the Mandelbrot setwasm/mandelbrot-tinygo.wasm
- Compiled TinyGo module that computes the Mandelbrot setwasm/mandelbrot-rust.wasm
- Compiled Rust module that computes the Mandelbrot set
Note: js/mandelbrot.js
loads the AssemblyScript module, but you can change it to test the other language's modules.
Building:
This depends on having the waPC CLI installed.
make
This installs dependencies, runs the wapc generate
command to generate the biolerplate code from schema.widl
, and compiles the AssemblyScript module.
Running:
You can start an HTTP server from this directory (so long as .wasm
files are served with a Content-Type
of application/wasm
). If you have node installed you can run the following command to start a simple static server.
node server.js
Then point your browswer to http://localhost:8888.
Finally, to demonstrate the portability of waPC modules, you can run a simple Go program to export the rendered image to a png.
make png