Skip to content

Geometric Patterns

Create mesmerizing patterns using Scene.with_grid(), math, and polygon shapes. No images needed.

Checkerboard with Shape Variations

Alternate between two shape types on a checkerboard:

for cell in scene.grid.checkerboard("black"):
    cell.add_polygon(Polygon.diamond(size=0.75), fill=colors.primary, opacity=0.7)

for cell in scene.grid.checkerboard("white"):
    cell.add_polygon(Polygon.hexagon(size=0.6), fill=colors.accent, opacity=0.5)

Checkerboard

Diamonds and hexagons on alternating cells.

Rotating Hexagonal Tiling

Position and product drive rotation for an organic feel:

for cell in scene.grid:
    nx, ny = cell.normalized_position
    rotation = (nx * ny) * 120
    cell.add_polygon(
        Polygon.hexagon(size=0.8),
        fill=colors.primary, stroke=colors.secondary, stroke_width=0.5,
        opacity=0.3 + (nx + ny) / 2 * 0.6, rotation=rotation,
    )

Rotating hexagons

Hexagons rotate by the product of their coordinates — organic turbulence.

Sine Wave Pattern

Sine functions create flowing, rhythmic patterns:

for cell in scene.grid:
    nx, ny = cell.normalized_position
    wave = math.sin(nx * math.pi * 4 + ny * math.pi * 2)
    size = 0.3 + abs(wave) * 0.5
    cell.add_polygon(
        Polygon.diamond(size=size),
        fill=colors.primary if wave > 0 else colors.accent,
        opacity=0.4 + abs(wave) * 0.6,
        rotation=wave * 45,
    )

Sine wave

Diamonds sized and colored by a 2D sine function — peaks in one color, troughs in another.

Concentric Rings

Use distance_to() to create radial patterns:

center = scene.grid[10][10]
for cell in scene.grid:
    ring = int(cell.distance_to(center) / 48) % 2   # ~48px-wide rings
    if ring == 0:
        cell.add_polygon(Polygon.hexagon(size=0.7), fill=colors.primary)
    else:
        cell.add_dot(radius=0.2, color=colors.secondary)

Concentric rings

Alternating ring zones with hexagons and dots.

Star Grid

Star point count and inner ratio driven by grid position:

Star grid

Stars evolve from 4-pointed with narrow arms (top-left) to 8-pointed with wide arms (bottom-right).

← Image to Art Flowing Curves →