Skip to content

benc-uk/rust-wasm-fractals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FractalRust - Fractals in Rust with WASM

This is a experiment and learning project for rendering Mandelbrot and Julia sets using Rust and displaying them in a web browser via WASM.

Features:

  • Interactively explore the fractal via the mouse with pan and zooming
  • Mandelbrot and Julia sets
  • A range of colour pallettes to pick from
  • Configurable options such as image size, colour scaling, inner set colour.
  • Export images as PNG

A couple of supporting projects are used, WASM-Pack and wasm-bindgen

One principal was to keep the Rust code loosely coupled, and free from any dependencies on the WASM/hosting layer, which in this case is JavaScript. So although wasm-bindgen is used, there is no use of js-sys or web-sys, the exported Rust code exposes just simple arrays of basic types (e.g. integers and floats).

The web layer is pure JavaScript & HTML, and requires no bundling, WebPack or transpiling.

Screenshots

See the examples folder for more

Running Locally

Pre-reqs

Steps

Deploying

To deploy the app, ESBuild is used to combine the HTML and JS in the web folder with the WASM and JS in the pkg folder, and create an output bundle.

Simply run make deploy.

See build.mjs file for more details