A hands-on harmonic-analysis playground where stacked rotating epicycles trace a hand-drawn or preset waveform in real time. It turns Fourier series from an abstract formula into something you can literally grab, scrub, and watch resolve term by term.
// Drop the standalone fourier-epicycle-lab.html into /public/effects/fourier-epicycle-lab.html
// Or copy the HTML/CSS/JS tab directly into your component — zero external dependencies.
export function FourierEpicycleLabEmbed() {
return (
<div className="relative min-h-[480px] w-full overflow-hidden rounded-2xl border border-white/10">
<iframe
src="/effects/fourier-epicycle-lab.html"
title="Fourier Epicycle Lab"
className="h-full min-h-[480px] w-full border-0"
loading="lazy"
/>
</div>
)
}Loading single-file HTML…
Build a single-file, zero-dependency 'Fourier Epicycle Lab' — a dark, mathematically crisp EdTech canvas (bg #05070a, primary #10b981, secondary #06b6d4, text #e6edf3). Layout: a large square stage centered, with a slim control rail beneath it on mobile and beside it on desktop (>=900px). Structure the stage as a <canvas> for the rotating epicycles plus an overlaid SVG for the traced path and guides. Mechanics: decompose the user's drawn waveform (or a preset square/saw/triangle wave sampled into ~64 points) into complex Fourier coefficients with a naive DFT. Animate each harmonic as a circle whose radius is the coefficient magnitude and whose angular velocity is its frequency index. The pen at the tip of the highest harmonic draws the reconstructed curve, while the original target waveform shows faintly behind it. Expose: an 'Terms' range slider (1–48 harmonics) that visibly morphs the shape from wobbly to sharp, a 'Speed' slider, and preset chips. Include a 'Draw your own' mode capturing pointer strokes on the stage with full touch support (pointerdown/move/up, touch-action: none). Polish: faint grid lines, a soft glow (canvas shadowBlur only on the pen), tabular-nums readouts for harmonic count and RMS error. Respect prefers-reduced-motion by rendering a static single frame instead of looping. Keep everything under 16 KB; no libraries.
WHY THIS WORKS IN PRODUCTION
- Draw any waveform and watch epicycles reconstruct it live
- Harmonic slider morphs wobbly sine into sharp square wave
- Full pointer + touch drawing with touch-action: none
- Static frame fallback under prefers-reduced-motion
DROP-IN SPECS // WEB & MOBILE FIT









