Skip to content

Expanding Hexagons

By the end of this lab you'll be able to:

  • Draw concentric hexagons that grow outward from the center
  • Rotate alternating hexagons 30° to create a more complex illusion
  • Understand how color gradients enhance the sense of depth and motion

Concentric hexagons, alternating between two rotations — 0° and 30°. The color gradient from dark center to light edges creates a strong illusion of a hexagonal tunnel or a surface expanding toward you.

Welcome to Expanding Hexagons!

Monty waving welcome Hexagons tile perfectly — six around each center, all fitting without gaps. Concentric hexagons with alternating rotations create a dizzying depth illusion! Let's code it together!

How It Works

Draw n concentric regular hexagons. Each hexagon is centered at the origin, with radius increasing by a fixed step. Odd-numbered hexagons are rotated 30° from even ones. Colors fade from dark navy at the center to light blue at the edge.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import turtle
import math
monty = turtle.Turtle()
monty.speed(0)
monty.hideturtle()

n_hexagons = 12
r_step = 12

for i in range(1, n_hexagons + 1):
    r = i * r_step
    rotation = 30 if i % 2 == 0 else 0
    t = 1 - i / n_hexagons
    blue_val = int(50 + 200 * (1 - t))
    monty.pencolor(0, int(50 * t + 50), blue_val)
    monty.pensize(max(1, n_hexagons - i + 1) // 2)
    monty.penup()
    monty.goto(r, 0)
    monty.setheading(90 + rotation)
    monty.pendown()
    for _ in range(6):
        monty.forward(r)
        monty.left(60)

What Do You Think Will Happen?

Monty thinking Alternating hexagons at 0° and 30° — will they look like separate shapes or a unified pattern? Make your guess — then click Run to find out!

Try It Now


  

A hexagonal tunnel — the alternating rotation and color gradient create a strong sense of depth. Were you right?

How It Works

The inner hexagons are drawn with thicker lines (more prominent), the outer ones with thinner lines. The color gradient from dark (center) to light (edge) reinforces the tunnel illusion — objects further away appear lighter. The 30° alternation prevents the simple "telescope" look and creates star-like complexity.

Explanation Table

Line What it does
rotation = 30 if i%2==0 else 0 Alternate 0° and 30° rotations
t = i / n_hexagons Progress from 0 (center) to 1 (edge)
int(30 + 200 * t) Blue value increases toward edge
pensize(...) // 2 Thick inner, thin outer lines

Learning Check

Your Turn — Try Pentagons

Monty thinking Change range(6) to range(5) and left(60) to left(72) in the inner loop. Predict: will 5-sided pentagons create a similar illusion?


  

Concentric pentagons with 36° alternation — a pentagonal tunnel, less symmetric than hexagons but equally hypnotic.

Experiments

  1. Remove the rotation alternation. Set rotation = 0 always. You'll know it worked when all hexagons align and the star-pattern disappears.

  2. Try triangles. Change to 3 sides, left(120), rotation = 60. You'll know it worked when nested triangles appear.

  3. Use a warm color gradient. Change the color to red/orange: pencolor(int(50+200*t), int(100*t), 0). You'll know it worked when the tunnel looks like glowing embers.

  4. Increase n_hexagons. Try n_hexagons = 20. You'll know it worked when the tunnel extends much further inward.

Hexagonal Hypnosis!

Monty celebrating You created a geometric optical illusion using only concentric hexagons! Op Art proves that math, color, and repetition can fool the visual system. Up next: Category 9 — Typography Patterns!