Have a jalebi.

May 20, 2023

(31mo ago)

3 min read

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.

Thought

What if you could take the geometry of jalebi: imperfect spirals, organic loops and make them come alive on a terminal screen?

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.

Info
The Archimedean spiral grows linearly with angle — r(θ) = a + bθ — making it perfect for evenly spaced loops. The jalebi twist comes from adding a sinusoidal perturbation: + c sin(dθ).

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.
Warning

This code will run an infinite loop for animation. Make sure to stop it manually when you're done admiring the spiral!

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

Similar Posts

Here are some other articles you might find interesting.

piyush raj emblem

I'm Piyush and I research on all things computer science, with a special focus on applied computer security.

© 2025 Piyush Raj