Skip to content

Mirror Butterfly

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

  • Create bilateral symmetry by negating the x-coordinates of a list of waypoints
  • Draw the right wing of a butterfly using goto() waypoints, then mirror it automatically
  • Understand how (x, y) → (-x, y) produces a perfect mirror reflection

A colorful butterfly built from two coordinate lists — the right wing drawn from waypoints, the left wing created automatically by negating all x-coordinates. One list, two wings.

Welcome to the Mirror Butterfly!

Monty waving welcome Every butterfly has bilateral (mirror) symmetry — the left wing is exactly the mirror of the right. In code, mirroring is just one character: a minus sign! Let's code it together!

How It Works

The right wing is defined as a list of (x, y) waypoints. To get the left wing, we create a new list where every x is negated: (-x, y). We draw both wings using goto() and begin_fill()/end_fill().

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
24
25
26
27
28
29
30
31
32
33
import turtle
monty = turtle.Turtle()
monty.speed(0)
monty.hideturtle()

right_wing = [
    (0, 0), (20, 40), (60, 80), (100, 90), (130, 60),
    (120, 20), (90, -10), (60, -20), (30, -30), (10, -40), (0, -50),
    (20, -80), (50, -100), (60, -70), (40, -60), (20, -50), (0, 0)
]

left_wing = [(-x, y) for x, y in right_wing]

def draw_wing(waypoints, color):
    monty.penup()
    monty.goto(waypoints[0])
    monty.pendown()
    monty.color(color)
    monty.begin_fill()
    for x, y in waypoints[1:]:
        monty.goto(x, y)
    monty.end_fill()

draw_wing(right_wing, 'darkorange')
draw_wing(left_wing, 'darkorange')

monty.penup()
monty.goto(0, -120)
monty.pendown()
monty.pencolor('black')
monty.pensize(3)
monty.setheading(90)
monty.forward(200)

What Do You Think Will Happen?

Monty thinking The left wing is created with (-x, y). Will it look like a perfect mirror of the right, or will it look upside down? Make your guess — then click Run to find out!

Try It Now


  

A perfect mirror — negating x flips the shape left-to-right without changing top-to-bottom. Were you right?

How It Works

[(-x, y) for x, y in right_wing] is a list comprehension that transforms every coordinate pair. The - before x flips horizontally. The y stays the same so there's no vertical flip.

The black body is drawn as a vertical line from tail to head using setheading(90) (straight up) and forward(200).

Explanation Table

Line What it does
right_wing = [(x,y), ...] Waypoints defining the right wing shape
[(-x, y) for x, y in right_wing] Mirror: negate all x-coordinates
monty.goto(x, y) Move turtle to each waypoint, drawing as it goes
begin_fill() / end_fill() Fill the wing shape

Learning Check

Your Turn — Flip Vertically Instead

Monty thinking Change (-x, y) to (x, -y) to flip vertically instead of horizontally. Predict what the result will look like — then run it to check!


  

(x, -y) flips top-to-bottom — the bottom wing is the vertical reflection of the right wing, in a different color to distinguish them.

Experiments

  1. Add wing markings. After drawing the filled wings, add a smaller right_inner list with fewer points and draw it with pencolor('black') and no fill. You'll know it worked when the wings have outlines.

  2. Change the body. Replace the straight line body with a series of dots in decreasing size. You'll know it worked when the body looks segmented.

  3. Use 4 wings. Also draw left_wing and bottom_wing to make a four-winged dragonfly. You'll know it worked when four wings radiate from the center.

  4. Add antennas. After the body, draw two thin lines from the top of the body curving outward. You'll know it worked when the butterfly has antennas.

Beautiful Symmetry!

Monty celebrating You used (-x, y) to create perfect bilateral symmetry — the same math used in computer animation to mirror a character's left and right sides! Up next: Truchet Tiles — random tiles that form unexpected global patterns.