Julia Set Pixel Art¶
By the end of this lab you'll be able to:
- Modify the Mandelbrot iteration to compute a Julia set by swapping
zandc - Understand how changing one complex constant
cproduces dramatically different shapes - Compare connected vs. disconnected Julia sets (Fatou dust)
The Julia set for c = -0.7 + 0.27i — a connected, swirling shape sometimes called the "Douady rabbit." Change c and the whole shape transforms; some values give spirals, others give dust.
Welcome to the Julia Set!
In the Mandelbrot set, c changes for each pixel and z starts at 0.
In a Julia set, c is fixed and z starts at each pixel's position.
Swapping these two roles gives an entirely different fractal!
Let's code it together!
How It Works¶
For each pixel (px, py), set z = (pixel's complex position) and c = -0.7 + 0.27j (fixed). Repeatedly apply z = z² + c. Color by escape time. The set of points that never escape is the Julia set.
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 | |
What Do You Think Will Happen?
The Julia set for c = -0.7 + 0.27i is a connected blob with a swirling boundary.
Will it look more like the Mandelbrot, or completely different?
Make your guess — then click Run to find out!
Try It Now¶
The Julia set looks very different from the Mandelbrot — it's a symmetric, swirling connected shape. Were you right?
How It Works¶
The key difference from Mandelbrot:
- Mandelbrot: z = 0, c = pixel_position — tests each point as a parameter
- Julia: z = pixel_position, c = fixed — tests each point as an initial value
The Julia set is connected if and only if c is inside the Mandelbrot set.
Explanation Table¶
| Line | What it does |
|---|---|
c = complex(-0.7, 0.27) |
Fixed parameter — determines the Julia shape |
z = complex(zr, zi) |
Starting value = current pixel position |
z = z * z + c |
Same iteration as Mandelbrot — but c never changes |
zr = -1.5 + px * 3.0 / cols |
Map pixel to complex z-plane x-coordinate |
Learning Check¶
Your Turn — Try a Different c Value
Change c = complex(-0.7, 0.27) to c = complex(0.285, 0.01).
Each c value creates a completely different Julia set. Predict whether it'll look
similar or very different — then run it to explore!
c = 0.285 + 0.01i is very close to the edge of the Mandelbrot set — the resulting Julia set has a feathery, spiraling boundary.
Experiments¶
-
Try
c = complex(-0.4, 0.6). This creates a "dragon" shape. You'll know it worked when you see a jagged, asymmetric form. -
Try
c = complex(0.0, 1.0). This is outside the Mandelbrot set — the Julia set becomes "Fatou dust" (disconnected scattered points). You'll know it worked when most pixels are colored, not black. -
Higher max_iter. Change
max_iter = 50. More iterations reveal finer boundary detail. You'll know it worked when the transition between colors is smoother. -
Widen the view. Change
zr = -2.0 + px * 4.0 / colsandzi = -1.67 + py * 3.33 / rows. You'll know it worked when the full Julia set fits in the frame.
Two Fractals, One Rule!
The Mandelbrot and Julia sets use exactly the same iteration — just with z and c swapped!
That tiny change gives you an infinite family of different fractals from one formula.
Up next: Sierpiński Carpet — 8-way recursive subdivision.