Drawing a butterfly in C and Common Lisp



Tags: #c #commonlisp #graphics

Created on April 23rd, 2026.

Hamid Naderi Yeganeh is an artist who draws with mathematical equations: every pixel’s color comes from a formula in (x, y).

His Morpho butterfly is one of these pieces:

Original Morpho butterfly by Hamid Naderi Yeganeh, with its equations

More of his work: X, Instagram, YouTube.

Two GitHub repositories reproduce the drawing above, one in C (https://github.com/occisn/c-morpho-butterfly) and one in Common Lisp (https://github.com/occisn/cl-morpho-butterfly).

The hardest part of the work was avoiding typos in the equations.

The computations are parallelized — OpenMP on the C side, lparallel on the Common Lisp (SBCL) side.

The Common Lisp (SBCL) code runs in the same order of magnitude as C. “Morpho butterfly” is used as a reference case on this C/CL comparison page.

Both programs produce the same butterfly:

The generated Morpho butterfly