Skip to content

Generative

m4bwav edited this page Nov 15, 2026 · 2 revisions

Each command writes a PNG; flame, lsystem and attractor also write a recipe JSON that redraws it, while ifs, attractor-search, fif and terrain print their parameters.

flame

Fractal flames after Draves and Reckase: a chaos game over transforms with 12 variations, a final transform, colour blending, log-density tone mapping and density estimation. Presets sierpinski and swirl-sierpinski, or a recipe. With no preset it scores seeded random flames on coverage and keeps the best (--seed N --tries 24).

python fw.py flame sierpinski -o flame.png
wrote flame.png and flame.json (coverage 0.117)

lsystem

Presets: koch, koch-snowflake, dragon, hilbert, sierpinski-arrowhead, plant-a, plant-b, plant-d, plant-e, plant-f, plant-stochastic. --n sets the generations, --seed the stochastic plant. Writes an SVG too.

python fw.py lsystem koch -o koch.png --n 4
wrote koch.png, koch.svg and koch.json (256 segments)

attractor

Strange attractors with density shading: clifford, dejong, the symmetric icons icon, icon-3, icon-halloween, icon-clam, icon-streamers and icon-flower (since 0.7.0 every icon preset is checked against Field and Golubitsky's Symmetry in Chaos), and the flows lorenz, chen, lu and multiscroll (the last three since 0.7.0). --params a,b,c,d overrides the preset; --search ranks random Clifford or de Jong sets by Sprott's rule.

python fw.py attractor clifford -o clifford.png
wrote clifford.png and clifford.json (coverage 0.333)
python fw.py attractor icon-flower -o flower.png --size 128x128
python fw.py attractor chen -o chen.png --size 128x128
wrote flower.png and flower.json (coverage 0.714)
wrote chen.png and chen.json (coverage 0.512)

ifs

Chaos-game IFS presets: sierpinski, fern, unequal-tiles. Probabilities follow each map's |det|, the first 20 points are dropped, and the frame is a ball proven to hold the attractor.

python fw.py ifs fern -o fern.png
fern: p = [0.01, 0.765, 0.11, 0.115], envelope centre (1.5519, 4.9796) radius 5.3113
wrote fern.png

attractor-search

Searches Sprott's quadratic maps and ranks them by correlation dimension D2 near 1.1-1.5 and a small Lyapunov exponent L (a rule from the book, with L in bits per iteration).

python fw.py attractor-search --hits 2 -o best.png
2 attractors in 39 tries (ranked by distance from D2 1.1-1.5, small L; book rule)
  EGQIHCRALSMRT  L 0.3026 bits/iter  D2 1.462  score 0.0303
  EHMMYRTAHYGMV  L 0.4693 bits/iter  D2 1.163  score 0.0469
wrote best.png (EGQIHCRALSMRT)

fif

A fractal interpolation function through given points, with one vertical scale factor per interval in --d. --numbers y.txt reads the values from a file.

python fw.py fif --points "0,0;1,1;2,0" --d 0.5,-0.5 -o fif.png
FIF through 3 points, sum|d| 1.000, graph dimension 1.0000
wrote fif.png

terrain

An fBm heightfield, spectral by default or --method midpoint (whose creases are measured), with Hurst exponent --H. Writes a PNG and a .npy for measure heightmap.

python fw.py terrain -o terrain.png
wrote terrain.png (spectral, 512x512, H 0.8, crease ratio 1.000)

Measuring a curve

python fw.py measure box koch.png
dimension: 1.1612
decades: 2.0000
verdict: fractal-like over 2.00 decades (D alone cannot identify the shape)

Three lines of the full output (its layout is in Commands). The Koch curve's true dimension is log 4 / log 3 = 1.2619; at generation 4 and 800 px the fit reads low, which is why the verdict line matters more than the number.

Clone this wiki locally