Create particle effect with Rust WASM & HTML Canvas

The previous post was a step-by-step tutorial on how to use wasm using Rust and run it in a browser. We built a simple web page with only an input field and a button. In this post, we will make something more interesting by creating a particle system in which 1000 randomly colored particles move in random directions at varying speeds. We will draw particles on HTML Canvas with all the logic done using the Rust wasm module.

Simple tutorial to run Wasm Rust module in a browser

Recently I was experimenting with WebAssembly, a binary format that can be executed in JavaScript environments, such as browsers. It was a lot of fun and I want to share how to create a simple web page that is using wasm module written in Rust language. We will use wasm-bindgen-cli tool to generate .js files and then create a web page that uses the wasm module and test what we created in the browser.