Flow Fields: Creating Organic Vector Patterns

What are Flow Fields?

Flow fields create stunning organic patterns using vector fields - mathematical functions that assign a direction to every point in space. By following these invisible flow lines, particles trace out beautiful, feather-like structures that feel both random and purposeful.

The result is art that looks like flowing silk, migrating birds in formation, or smoke caught in an updraft - organic complexity from simple directional guidance.

Why Use Flow Fields?

The Basic Idea

A flow field works like this:

  1. Define a vector field: Every point (x, y) has a direction vector (dx, dy)
  2. Sample the field: Draw lines that follow these directions
  3. Add variations: Slight randomness prevents perfect repetition
  4. Color by flow: Use color to indicate speed or direction of flow

The magic is in the vector field function - typically using sine waves at different frequencies and angles to create the swirling patterns.

Code Structure: Flow Field Generation

import numpy as np

def create_flow_field(filename, seed=42):
    """Create flow field pattern"""
    import random
    random.seed(seed)
    
    width = height = 1024
    
    # Create vector field function using sine waves
    def flow_direction(x, y, time=0):
        angle1 = np.sin(x / 50.0) + np.cos(y / 50.0) * 0.3
        angle2 = np.sin((x + y) / 80.0) * 0.5
        angle3 = np.random.uniform(-0.3, 0.3) if random.random() < 0.1 else 0
        
        direction = (angle1 + angle2 + angle3) % (2 * np.pi)
        return direction
    
    # Generate image by following flow lines
    img_data = np.zeros((height, width, 3), dtype=np.uint8)
    
    # Create particle paths that follow the field
    num_particles = 5000
    
    colors = [
        (240, 235, 225),  # Creamy white
        (210, 195, 160),  # Light gold
        (180, 160, 140),  # Golden brown
        (160, 140, 120),  # Warm tan
        (230, 240, 235),  # Soft blue-green
        (220, 225, 230),  # Pale greenish-blue
        (200, 210, 215),  # Neutral gray-blue
    ]
    
    for _ in range(num_particles):
        start_x = random.randint(0, width)
        start_y = random.randint(0, height)
        
        current_x, current_y = start_x, start_y
        color_idx = random.randint(0, len(colors) - 1)
        color = colors[color_idx]
        alpha = random.uniform(0.02, 0.15)
        
        for _ in range(200):  # Line length
            direction = flow_direction(current_x, current_y)
            speed = random.uniform(1, 3)
            
            next_x = int(current_x + np.cos(direction) * speed)
            next_y = int(current_y + np.sin(direction) * speed)
            
            if 0 <= next_x < width and 0 <= next_y < height:
                img_data[next_y, next_x] = (
                    color[0] * alpha,
                    color[1] * alpha,
                    color[2] * alpha
                )
            
            current_x, current_y = next_x, next_y
    
    # Add subtle noise for organic feel
    noise = np.random.randint(0, 5, (height, width, 3)).astype(int)
    final_image = ((img_data + noise) % 256).astype(np.uint8)
    
    os.makedirs(os.path.dirname(filename) or '.', exist_ok=True)
    img = Image.fromarray(final_image)
    img.save(filename)
    print(f"Created {filename}")

The Vector Field: Creating the Flow

The key to flow fields is the vector field function itself. Mine uses:

This creates the feather-like branching patterns - each "feather" is actually a cluster of particles following similar flow directions.

Color Palette Selection

The dusk palette I used (warm golds, creams, soft greens) works beautifully with dark backgrounds:

Pro Tip: Try different vector field functions - replace sine with cosine, or mix in polynomial terms for completely different flow patterns.

Technical Parameters

Variations to Experiment With

  1. Different functions: Try polynomial, exponential, or custom math
  2. Motion over time: Animate by varying a "time" parameter
  3. Multiple layers: Blend different vector fields for complexity
  4. Color mapping: Map colors to flow speed or direction
  5. Better density: Adjust particle count and alpha values

The beauty of flow fields is that they feel alive - the patterns look like they're moving even though they're static images. The feather-like branching structures emerge naturally from following directional guidance.

Flow field organic vector pattern

Flow field creating delicate feather-like patterns


This technique reminds me that flow is fundamental to nature - rivers, wind, blood, thoughts. The mathematics of flowing captures something essential about how energy and information move through systems.