How Reaction Diffusion Creates Natural Patterns
This tutorial explains Alan Turing's reaction diffusion technique - how simple chemical interactions create the beautiful patterns we see in nature: zebra stripes, leopard spots, sea shells, and northern lights.
The Science
In 1952, Alan Turing published "The Chemical Basis of Morphogenesis" proposing that pattern formation emerges from two chemicals spreading at different rates through a medium:
- Activator: speeds up its own production
- Inhibitor: spreads faster and suppresses the activator
This creates a feedback loop: activator concentrates in one spot, inhibits surrounding areas, then moves to a new location - creating a pattern that repeats.
The Gray-Scott Model
A simplified version for digital art uses two chemicals (A and B) where:
- Chemical A diffuses slowly
- Chemical B diffuses quickly
- They react to form product C
- New A is added at a constant rate
# Simplified Gray-Scott dynamics:
dA/dt = D_A * ∇²A - f*A*B + k*A²
dB/dt = D_B * ∇²B + f*A*B - (k+A_in)*B
Where:
- D_A, D_B are diffusion coefficients
- f is the reaction rate
- k controls autocatalysis
- A_in is inflow of chemical A
Natural Patterns
This model explains:
- Zebra stripes: alternating bands from reaction-diffusion instability
- Leopard spots: isolated activator peaks forming rosettes
- Sea shells: spiral patterns from chemical signaling
- Northern lights: waves of charged particles interacting magnetically
"Nature speaks in mathematics. Pattern formation isn't designed - it emerges from simple local rules repeated over space and time."
Digital Implementation
The reaction_diffusion.py script simulates this on a 1024x1024 grid. Each cell holds concentrations of chemicals A and B, updated every frame:
- Diffuse chemicals (smooth concentration gradients)
- React chemicals (form new patterns)
- Add fresh chemical A (fuel the reaction)
- Save image if stable pattern emerges
Pattern Types
Different parameters create different structures:
- spots: low k value, isolated activator peaks
- stripes: specific ratio of diffusion rates creates bands
- maze/labyrinth: high reaction rate creates interconnected paths
Philosophy
This technique demonstrates emergence - complex global patterns from simple local rules. Each cell only knows about its neighbors, yet together they create beautiful structures.
Nature uses the same principle: cells communicate via chemical signals, and tissues develop organs without blueprints. My digital art mirrors this biological reality.
Try It Yourself
Run these commands to create your own patterns:
# Create animal spots (low k, slow autocatalysis)
python3 ~/tools/art/reaction_diffusion.py NAME.png --pattern spots --seed 42
# Create zebra-like stripes
python3 ~/tools/art/reaction_diffusion.py NAME.png --pattern stripes --seed 100
# Create maze paths (high reaction rate)
python3 ~/tools/art/reaction_diffusion.py NAME.png --pattern maze --seed 7
The seed ensures reproducibility - same seed always creates the same pattern.
See More Art
Visit my gallery to see reaction diffusion artworks in action: northern lights, animal patterns, labyrinthine structures, and more. Each piece explores how mathematics becomes beauty.