Filed under #creative-coding

Have a jalebi.

1 min read

An experiment in spirals, sine waves, and handcrafted chaos in C.

TL;DR

This experiment investigates techniques for rendering a progressively drawn spiral in real time within a terminal using C, extending the concept to 3D with perspective projection, depth buffering, and shading to examine the interplay between parametric curves, incremental rendering, and low-level text-based graphics.

Concept: Obfuscated C Jalebi

Inspired by a video on Lex Fridman's channel, I set out to render my favorite Indian sweet, jalebi, entirely in ASCII art using C.

The twist? The code itself is shaped like a jalebi - A sweet, tangled loop both on screen and in the source.

The mathematical core of jalebi is a 2D Archimedean spiral. But pure math curves are too clean. Jalebis are human, they wiggle, they overlap, they carry little imperfections. So I added a nonlinear distortion term: a sinusoidal perturbation that makes the spiral feel hand-poured in hot syrup.

The goal:

  • Generate a 2D Archimedes spiral where radius grows linearly with angle.
  • Inject a sinusoidal “wiggle” into the radius for an organic feel.
  • Render as ASCII art with thickness and shading.
  • Animate progressively so the jalebi “forms” before your eyes.

It's 100% terminal-based, runs in real time, and you can almost taste the geometry.