Mandelbrot — Canvas

Pure F# escape-time algorithm compiled to WebAssembly GC. JavaScript drives the pixel loop and canvas API; every escape-time calculation is a native WasmGC call.

Loading…

F# → WasmGC

compiled by fsharp-wasm

Plain JavaScript

reference implementation
F# source
let iterate (cx: float) (cy: float) (maxIter: int) : int =
    let mutable x = 0.0
    let mutable y = 0.0
    let mutable i = 0
    while i < maxIter && x * x + y * y < 4.0 do
        let xn = x * x - y * y + cx
        y <- 2.0 * x * y + cy
        x <- xn
        i <- i + 1
    i