sqlite-creative-coding
Creative coding in SQL
A collection of SQL queries that generate images and animations, Mandelbrot fractals, Voronoi diagrams, color gradients, using only SQLite and ImageMagick, as a creative coding experiment.
This repository explores generating images and short animations using nothing but SQL queries run against SQLite, a database engine usually associated with storing data rather than drawing pictures. The technique relies on a SQLite feature called recursive CTEs (Common Table Expressions), which let a query build up a result row by row in a loop, effectively computing the color of every pixel in an image through database queries alone.
The project includes six visual examples: a smooth color gradient, a Mandelbrot fractal (a classic mathematical shape with infinitely detailed edges), a pattern of polka dots, a Voronoi diagram (a type of geometric pattern where the plane is divided into regions based on distance from a set of points), and two animated pieces called Wavey and Rave that loop through frames to create movement. The static visuals are output as PNG files and the animations as GIF files, both produced by feeding SQLite's output through ImageMagick (a widely available image processing tool).
Running the project requires SQLite and ImageMagick installed on your system. A setup script initializes a small database file, and then individual SQL files for each visual can be run to generate the output. The repository includes a justfile for convenience so commands like "just image src/mandelbrot.sql" do all the steps in sequence. The SQL files themselves are the actual creative work, the full pipeline for generating each image lives inside the query.
The README is minimal and links to a blog post on the author's site for a fuller explanation of how the technique works. The whole project reads as a playful experiment: the author notes they generated visuals with SQL "because nobody stopped them."
Where it fits
- Generate Mandelbrot fractal PNG images entirely using SQLite recursive queries without any graphics library
- Create animated GIF files from SQL-driven pixel data piped through ImageMagick
- Study how recursive CTEs in SQLite can compute pixel colors row by row to understand advanced SQL looping