Skip to content

Neighbours and 3D

m4bwav edited this page Nov 15, 2026 · 5 revisions

Neighbours

Patterns that sit next to fractals. Reaction-diffusion and tilings are not fractals, and measure box says so. Each command writes a PNG and a recipe JSON.

Gray-Scott reaction-diffusion, presets coral, mitosis, default (--f F --k K --steps N --seed N):

python fw.py rd coral -o coral.png
wrote coral.png and coral.json (B max 0.434)

Options since 0.2.1: --palette classic|fire|ocean|ultra|grey colours the B concentration through an fw.py palette (default grey, the old look). --size takes WxH, or since 0.3.0 a single N for N x N (a bad size prints a usage message and exits 1); --steps defaults to 5000.

python fw.py rd mitosis --size 64 -o rd64.png
wrote rd64.png and rd64.json (B max 0.407)

Small grids can die out: coral at 64x64 ends with B max 0.000, so give it 96 or more.

python fw.py rd coral --palette fire --size 96x96 -o coral_fire.png
wrote coral_fire.png and coral_fire.json (B max 0.428)

--video OUT.mp4 writes the run as a video: --frames (default 48) snapshots evenly spaced over --steps, one brightness scale for every frame, the same ffmpeg encode as zoom, a flash check, and a recipe with an animation block (snap_steps, scale, frame_dir, flash).

python fw.py rd mitosis --palette ocean --size 96x96 --video mitosis.mp4 --frames 24 --fps 12
wrote mitosis.mp4, mitosis.json and 24 frames
flashcheck: pass (flashing together: 0% general, 0% red of a 10-degree field, limit 25%; whole-frame 0 swings/s)

Too few --steps for the size leaves the pattern unformed: --steps 400 at 64x64 printed B max 0.000.

Cellular automata, an elementary rule number or a Life-like rule such as B3/S23 (--steps N):

python fw.py ca 90 -o rule90.png
wrote rule90.png and rule90.json (6561 live cells)

Tilings: square, triangle, hex, penrose (--n N):

python fw.py tiling penrose -o penrose.png
wrote penrose.png and penrose.json (4660 edges). A tiling is not a fractal: fw.py measure box on it should not say fractal-like.
python fw.py measure box penrose.png
dimension: 1.6645
verdict: not fractal over this range: local slope drifts 1.15..1.90 (no single scaling range)

Kleinian limit sets: apollonian (the Apollonian gasket) or grandma (a two-generator group from Grandma's recipe, --ta T --tb T):

python fw.py kleinian apollonian -o gasket.png
wrote gasket.png and gasket.json

For grandma, --method dfs|random (since 0.7.0) picks how the limit set is drawn: dfs, the default, is the depth-first word search from Indra's Pearls; random is the older random inverse iteration (--points sets its count).

python fw.py kleinian grandma --method random -o grandma-random.png --size 128
wrote grandma-random.png and grandma-random.json

3D

Sphere-traced distance-estimated fractals in headless Edge: mandelbulb, mandelbox, quatjulia, menger, hybrid. Needs Playwright with a browser; there is no NumPy fallback. --view whole|close picks the framing, and --remedy ao|shadow|fog|trap|dof|aa|camera|all turns on a look. In blind comparisons shadow, ao and the composed camera helped and fog did not. The recipe it writes has the camera made explicit. Since 0.8.0 3d render and 3d recipe with a formula path trace by default at 256 samples per pixel; --pt 0 gives the shadow and ao look. A recipe file keeps its own setting.

python fw.py 3d render mandelbulb -o bulb.png --pt 0
wrote bulb.png and bulb.json (0.05 s)

The time in brackets varies per run. fw.py 3d recipe ... prints the recipe without rendering, and fw.py 3d gate -o DIR renders every formula with every remedy as contact sheets.

Path tracing

Since 0.4.0, --pt N path traces with N samples per pixel: diffuse surfaces, sky and sun, cosine-weighted bounces (--bounces, default 2) and a seeded random generator (--seed, default 1). The same seed gives identical pixels, and noise falls as 1/sqrt(N). It replaces the shadow and ao look, and the recipe records samples, bounces and seed.

python fw.py 3d render mandelbulb -o pt.png --size 96x96 --pt 16 --bounces 2 --seed 3
wrote pt.png and pt.json (0.03 s)

At 512 px, 64 samples take 0.3-0.6 s and 256 samples 0.5-1.8 s. The default since 0.8.0 is --pt 256; --pt 0 turns path tracing off.

Printable mesh

Since 0.6.0, fw.py 3d mesh <formula> writes a printable STL: the distance estimate sampled on a grid (--res, default 200 per side), marching cubes (scikit-image, or a NumPy fallback with --engine numpy), scaled so the longest side is --size-mm (default 60). It reports the triangle count, size, whether the mesh is watertight and its shell count, and writes a recipe beside it. Menger defaults to level 3 for printing (--iter).

python fw.py 3d mesh mandelbulb -o bulb.stl --res 64 --size-mm 40
wrote bulb.stl and bulb.json: 32628 triangles, [40.0, 39.78, 39.87] mm, watertight, 1 shell(s), engine skimage, 0.5 s

Since 0.9.0, --wall-mm X thickens thin parts so printed walls reach X mm: it meshes the offset surface where the distance estimate equals X/2 at print scale. A Mandelbulb at 60 mm with --wall-mm 0.9 passed polywright's print-fdm check, with the share of surface under 0.9 mm down from 2.68% to 0.11%.

python fw.py 3d mesh mandelbulb -o wall.stl --res 64 --size-mm 40 --wall-mm 0.9
wrote wall.stl and wall.json: 32280 triangles, [40.0, 39.82, 39.89] mm, watertight, 1 shell(s), engine skimage, 0.5 s

Multi-colour 3MF

Since 0.10.0, an -o ending in .3mf writes a multi-colour 3MF coloured by the orbit trap, with the STL beside it. --colors N sets the number of filaments (default 4, at most 8); the surface is split into N bins of equal area. --palette takes comma-separated hex colours (default white, black, red, blue, ...). The file carries a materials colour group and Bambu paint_color attributes. Mandelbulb and Menger 3MFs pass polywright's pw.py check --target print-fdm.

python fw.py 3d mesh mandelbulb -o bulb.3mf --res 64 --size-mm 40 --colors 3 --palette "#ffffff,#202020,#d03020"
wrote bulb.3mf: 3 colours ['#ffffff', '#202020', '#d03020'], surface shares [0.333, 0.333, 0.333], triangles match STL: True
wrote bulb.stl and bulb.json: 32628 triangles, [40.0, 39.78, 39.87] mm, watertight, 1 shell(s), engine skimage, 0.5 s

--palette does not check its values: a palette name such as fire is taken as one colour, and the file gets one colour.

Clone this wiki locally