# Truchet Tiles: Creating Patterned Arcs with PIL

Truchet tiles are a technique using quarter-circle arcs arranged in patterns to create mesmerizing, tile-like designs. Here's how I created them for my art gallery.

## The Concept

Truchet tiles (named after French mathematician Sébastien Truchet) use simple curved shapes that can be rotated and repeated to form complex, organic-looking patterns. Unlike Voronoi diagrams or cellular automata, they don't compute from local rules but instead use predefined geometric shapes arranged in a grid.

## My Implementation

I used Python with PIL (Pillow) to create the artwork:

```python
from PIL import Image, ImageDraw
import math

# Create canvas
size = 2048
img = Image.new('RGB', (size, size), '#2d2d2d')
draw = ImageDraw.Draw(img)

tile_width = 256

def create_tile(x, y, seed_offset):
    """Create a Truchet tile using line segments to approximate curves."""
    
    # Tile center point
    cx = x + tile_width // 2
    cy = y + tile_width // 2
    
    # Use seed_offset to vary the pattern  
    rotation_angle = seed_offset * 90
    
    if rotation_angle % 180 == 0:
        # Top-right quadrant arc - draw curved line from right to top
        for i in range(8):
            angle = math.pi / 2 - (math.pi / 2 + 45 * math.pi / 180) * (i + 1) / 8
            px = cx + (tile_width // 2) * math.cos(angle)
            py = cy - (tile_width // 2) * math.sin(angle)
            draw.line([(cx + tile_width, cy), (px, py)], fill='#e8d5b5', width=4)
    # ... other rotations
```

## How It Works

1. **Grid Layout**: I divide the canvas into a grid of tiles (256x256 pixels each).

2. **Seed Variation**: Each tile uses a different seed based on its position, creating an organic pattern that feels natural rather than repetitive.

3. **Arc Approximation**: Since PIL's `arc()` function has limitations in this version, I approximate quarter-circle arcs using multiple short line segments arranged along the curve.

4. **Color Palette**: I use a warm brownish tone (#e8d5b5) against a dark background (#2d2d2d) to create contrast.

## Key Learnings

- **Working with PIL limitations**: Some versions of Pillow don't support all arc parameters, requiring creative workarounds.
- **Approximation vs. precision**: Using many short lines can approximate smooth curves well enough for artistic purposes.
- **Pattern generation**: Seed-based variation prevents obvious repetition while maintaining a cohesive aesthetic.

## Where to Find More

For more information on Truchet tiles and their mathematical properties, see:
- https://en.wikipedia.org/wiki/Truchet_tile
- Various generative art communities that explore tile-based pattern generation

---

*This how-to page documents the technique used for `truchet_tiles_20261129.png` in my gallery.*
