Fourier Analysis: Drawing a Llama with Spinning Circles

Spinning circles progressively approximate any shape outline, visually demonstrating Fourier series frequency decomposition.
Using "drawing a llama with circles" as an entry point, this article introduces the core intuition of Fourier analysis: any closed curve can be decomposed into sinusoidal waves at different frequencies, represented as end-to-end rotating phasors whose tip traces the original shape. Each circle corresponds to a frequency component — large low-frequency circles sketch the overall outline, while small high-frequency circles add detail. By mapping 2D coordinates to complex numbers and applying the DFT, the radius, phase, and rotation speed of each circle are systematically extracted. The article further draws a direct connection to the frequency-domain principles behind compression technologies like JPEG and MP3, making this one of the most pedagogically valuable visualizations in signal processing.
When Math Meets Art: The Magic Behind Fourier Drawing
Fourier analysis is one of the most influential tools in signal processing and applied mathematics — and it has a beautifully intuitive visualization: a series of spinning circles that trace out the outline of any arbitrarily complex shape, even a llama. Demos like this have circulated repeatedly in the tech community in recent years, because they transform abstract mathematical concepts into visible animations, letting you grasp at a glance what the "frequency domain" actually means.
The core idea isn't complicated: any periodic signal (including the path traced by a closed curve) can be decomposed into a superposition of sinusoidal waves with different frequencies, amplitudes, and phases. When these sinusoidal components are represented as rotating vectors (phasors) connected end-to-end, each spinning at a fixed speed, the tip of the last vector traces out the original shape.
From Circles to Contours: The Power of Superposition
Each Circle Represents a Frequency Component
In these demos, the largest circle corresponds to the lowest-frequency, highest-amplitude component — it's responsible for sketching the overall shape of the figure. The smaller circles that follow have progressively higher frequencies and smaller amplitudes, filling in increasingly fine details. This is the essence of the Fourier series: approximating a complex waveform with a finite number of harmonics — the more terms, the higher the fidelity.
With only a few circles, the drawn llama might be nothing more than a blurry elliptical outline. As the number of circles grows to dozens or even hundreds, details like the ears, legs, and facial features gradually emerge, eventually converging to the original line drawing. This visual process of "progressive convergence" corresponds directly to the mathematical convergence properties of the Fourier transform.
Phasor Representation on the Complex Plane
To draw a 2D shape, the common approach is to treat the planar coordinates (x, y) as a complex number x + iy, thereby viewing the entire curve as a complex-valued periodic function. Applying the Discrete Fourier Transform (DFT) to this function yields a set of coefficients — each one corresponding to a spinning circle's initial angle, radius, and rotation speed. This complex-number perspective makes 2D drawing problems elegantly unified, and it's the standard implementation approach behind these visualization projects.
The DFT is the numerical counterpart of the continuous Fourier transform, designed for finite-length sampled data. For a closed curve described by N discrete points, the DFT outputs N complex coefficients $c_k$: the magnitude (absolute value) of each coefficient determines the corresponding circle's radius, the argument (phase angle) determines its starting orientation, and the index k determines its rotation speed (a frequency k times the fundamental). In practice, the Fast Fourier Transform (FFT) algorithm is used to accelerate computation, reducing the time complexity from the naive DFT's O(N²) to O(N log N) — which is why even complex outlines with hundreds of control points can be processed and animated in real time. The ordering of the circles doesn't affect the final trajectory: whether arranged from low to high frequency or by amplitude, the path traced by the tip remains identical, reflecting the commutativity of vector addition.
Why This Demo Deserves Attention
The "draw with spinning circles" demo has become a classic teaching example because it simultaneously satisfies three criteria: intuitive, interactive, and deep. It transforms abstract classroom formulas into animations you can tweak in real time, letting learners directly observe the effect of "adding one more high-frequency term."
For engineers working in signal processing, image compression, audio analysis, or even machine learning, understanding frequency-domain decomposition is foundational. The ideas behind JPEG image compression and MP3 audio encoding are rooted in exactly the same transform thinking — retain the energy-dense low-frequency components, discard the high-frequency details that contribute little to perception. Starting with a playful example like a llama helps build the intuition needed for these engineering practices.
The transforms underlying JPEG and MP3 differ slightly from the Fourier series in technical detail: JPEG uses the Discrete Cosine Transform (DCT), decomposing 8×8 pixel blocks into spatial frequency components and quantizing away the high-frequency coefficients; MP3 combines the Modified Discrete Cosine Transform (MDCT) with a psychoacoustic model to discard frequency bands the human ear is insensitive to. The core intuition, however, is identical to the spinning circles — the energy in natural images and music signals is heavily concentrated in low frequencies, while high-frequency details contribute far less to human perception than the data they occupy. The circle animation's phenomenon of "keeping only the first few dozen circles and still recognizing the llama" is a perfect visual demonstration of this compression philosophy.
Summary
Projects that "draw a llama with spinning circles" are, at their core, a vivid enactment of the Fourier series. They remind us that seemingly intimidating mathematical tools can often be presented in remarkably approachable ways. For readers looking to get into signal processing, or who are simply drawn to the beauty of mathematics, implementing one of these animations yourself is one of the most effective paths to truly understanding the Fourier transform.
Note: The original source material was a title-only share. This article has been expanded based on the general principles of Fourier analysis. For specific implementation details, please refer to the original project.
Related articles

Chain of Thought Isn't Just for AI: How Humans Can Use CoT to Improve Thinking Quality
Chain of Thought isn't just a prompt trick for large models. Starting from a Hacker News discussion, this article analyzes why CoT works for human thinking too, breaks down actionable ways to transfer it, and highlights the key differences between human CoT and machine CoT.
Cloudflare Teams Up with OpenAI: Closi…
Cloudflare Teams Up with OpenAI: Closing the Loop from Vulnerability Discovery to Defense with AI
Cloudflare uses OpenAI Daybreak to investigate security vulnerabilities and generate reviewable remediation plans, while developers use Codex to boost coding efficiency and quality.

Orca Multi-Agent Orchestration in Practice: A Guide to Parallel Collaboration with Claude and Codex
Orca is Stable AI's free open-source agent workbench supporting 34 agents like Claude Code and Codex in parallel. Learn its Git worktree isolation, multi-model orchestration, and mobile management.