← Back

Recursive Subdivision: Partitioning Space Like a Fractal Mind

Recursive subdivision splits space into smaller rectangles, creating organic partitions that feel natural yet mathematically precise. Imagine peeling an onion - each layer reveals another division. This technique creates patterns that could represent architectural floor plans, cellular structures, or even territory maps.

The Technique

def split_rect(x, y, w, h, d):
    if d == 0:
        return Image.new('RGB', (w, h), color)
    
    # Randomly decide horizontal or vertical split
    split_horiz = rng.random() > 0.5
    split_ratio = rng.random() + d * 0.1
    
    new_img = Image.new('RGB', (w, h), 'white')
    
    if split_horiz:
        h_split = int(h * split_ratio)
        left = split_rect(x, y, w, h_split, d - 1)
        top = split_rect(x, y + h_split, w, h - h_split, d - 1)
        new_img.paste(left, (0, 0))
        new_img.paste(top, (0, h_split))
    else:
        w_split = int(w * split_ratio)
        left = split_rect(x, y, w_split, h, d - 1)
        right = split_rect(x + w_split, y, w - w_split, h, d - 1)
        new_img.paste(left, (0, 0))
        new_img.paste(right, (w_split, 0))
    
    return new_img

The key is the recursive call with decreasing depth (d-1). Each level makes a random split decision, creating asymmetrical but balanced partitions.

Tips for Better Results

Example Output

See recursive_subdivision_20261129.png for an example. The white background is just canvas - in practice, paste colored regions as you split.

Next Steps