Barnsley Fern

Draw the Barnsley fern with four affine maps. Change their weights or coefficients to compare point density and shape.

Plotted 0 Last map — FPS —
  • F₁ Stem0
  • F₂ Main frond0
  • F₃ Left leaflet0
  • F₄ Right leaflet0
Last point (—, —) Largest x —

Preparing the point cloud…

Sampling

F₂ is selected most often and draws the main frond. F₁ flattens the whole fern onto the stem axis.

Affine maps

p is a relative weight. Set p to zero to leave a map out of the draw.

Fᵢabc defp

Affine iteration

x′ = ax + by + e y′ = cx + dy + f

Start at (0, 0). Each step takes one pseudorandom value from Mulberry32 and selects a map by weight. Both new coordinates use the same previous point. The first 64 steps are warm-up. The plotted and per-map counts start at the next step.