Hover the Mandelbrot set on the left: the Julia set of the point under the
cursor is drawn on the right, live. Click to zoom in, shift-click to zoom
out. Every pixel of both images is computed by
fractal.lisp, compiled to a ~2.5 KB WebAssembly component and transpiled with
jco.
This is what the page does to talk to the module — all of it:
const { mandelbrot, julia, palette, escapeTime, inSet } = await import("./dist/fractal.js");
const chars = mandelbrot(centerX, centerY, scale, cols, rows, maxIter);
No WebAssembly.instantiate, no import object, no WASI shim, no
memory.buffer, no __ronto_alloc, no
(ptr, len) pair to decode. The
WIT world types the five exports, the
canonical ABI of the component model moves the strings across and frees
them, and jco generated the bindings by reading that world out
of the .wasm. Compare with the sibling
rainbow demo, whose page copies UTF-8
bytes into the module's linear memory through its bump allocator and decodes
a returned (ptr, len) pair, or with
webgl-galaxy, whose page hand-writes an
import object of dozens of host functions.
mandelbrot(center-x, center-y, scale, cols, rows, max-iter)
— hover to pick c, click to zoom.
julia(cx, cy, scale, cols, rows, max-iter) — the Julia
set of the hovered c, redrawn on every mouse move.