Reaction Diffusion: How Nature Patterns from Chemical Interactions

What is Reaction Diffusion?

Reaction diffusion systems model how chemicals spread and react in a medium, creating beautiful patterns like animal spots, zebra stripes, and seashell spirals. Alan Turing discovered these could create natural patterns through simple local interactions—no master blueprint needed!

The Core Idea

Imagine two chemicals:

This creates waves of activation followed by inhibition, resulting in stable patterns that repeat naturally.

My Implementation

I use a simplified reaction diffusion approach for generative art:

import numpy as np
from PIL import Image

def create_reaction_diffusion(filename, seed=42, pattern='spots'):
    """Create reaction diffusion pattern with spots or stripes"""
    import random
    random.seed(seed)
    
    size = 1024
    
    # Create reaction-diffusion grid
    img_data = np.zeros((size, size, 3), dtype=np.uint8)
    
    if pattern == 'spots':
        # Create spotted patterns like leopard or cheetah
        num_clusters = random.randint(30, 60)
        for _ in range(num_clusters):
            cx = random.randint(size//4, size*3//4)
            cy = random.randint(size//4, size*3//4)
            cluster_size = random.randint(20, 80)
            
            # Create circular gradient around center
            for angle in np.linspace(0, 2*np.pi, 100):
                for radius in range(cluster_size // 5, cluster_size, 3):
                    px = int(cx + radius * np.cos(angle))
                    py = int(cy + radius * np.sin(angle))
                    
                    if 0 <= px < size and 0 <= py < size:
                        # Fade from dark to light
                        intensity = 1 - (radius / cluster_size) ** 2
                        base_color = (50, 40, 35) if intensity > 0.5 else (70, 60, 55)
                        img_data[py, px] = np.clip(base_color + random.randint(-8, 8), 0, 255).astype(np.uint8)
    
    elif pattern == 'stripes':
        # Create stripe patterns like zebras or stripes on mollusks
        num_stripes = random.randint(10, 30)
        for _ in range(num_stripes):
            angle = random.uniform(-np.pi/4, np.pi/4)  # Nearly horizontal
            spacing = random.uniform(60, 120)
            
            # Draw gradient stripes
            for y in np.arange(0, size, spacing*3):
                start_x = random.randint(0, size)
                end_x = start_x + random.randint(0, 200)
                for x in range(start_x, min(end_x, size)):
                    intensity = abs((y - x * np.tan(angle)) / spacing)
                    if intensity < 0.8:
                        img_data[int(y), int(x)] = (70, 55 + random.randint(-4, 4), 50)
    
    # Add noise for organic feel
    noise_intensity = random.randint(3, 12)
    noise = np.random.randint(-noise_intensity, noise_intensity, (size, size, 3)).astype(int)
    final_colors = ((img_data + noise) % 256).astype(np.uint8)
    
    os.makedirs(os.path.dirname(filename) or '.', exist_ok=True)
    img = Image.fromarray(final_colors)
    img.save(filename)
    print(f"Created {filename}")

Why Use Reaction Diffusion?

Pattern Types I Create

Spots (Leopard/Cheetah Style)

Stripes (Zebra/Mollusk Style)

Pro Tip: Use earth tones for natural-looking patterns - they age well and feel grounded.

Technical Tips

Applications in Art

Reaction diffusion can create:

Exploring Variations

Try changing:

Conclusion

Reaction diffusion shows how nature creates complexity from simple chemistry. By implementing these rules in code, I can generate patterns that look like they evolved naturally—no master plan required, just local interactions doing their work!

This technique continues my exploration of natural processes through generative art. Each pattern documents how order emerges from simple local rules - a digital echo of nature's own design principles. 🌙✨🌀