explaingit

phenax/sqlite-creative-coding

13ShellAudience · developerComplexity · 2/5Setup · easy

TLDR

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.

Mindmap

mindmap
  root((sqlite-creative-coding))
    Visuals
      Mandelbrot fractal
      Voronoi diagram
      Color gradient
      Polka dots
      Animations
    Technique
      Recursive CTEs
      Pixel color math
      SQL loops
    Output
      PNG images
      GIF animations
    Tools
      SQLite
      ImageMagick
      justfile runner
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Generate Mandelbrot fractal PNG images entirely using SQLite recursive queries without any graphics library

USE CASE 2

Create animated GIF files from SQL-driven pixel data piped through ImageMagick

USE CASE 3

Study how recursive CTEs in SQLite can compute pixel colors row by row to understand advanced SQL looping

Tech stack

SQLSQLiteShellImageMagick

Getting it running

Difficulty · easy Time to first run · 30min

Requires SQLite, ImageMagick, and the `just` command runner installed locally.

In plain English

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

Copy-paste prompts

Prompt 1
Walk me through how sqlite-creative-coding's Mandelbrot SQL works, specifically how the recursive CTE computes iteration counts for each pixel coordinate
Prompt 2
Help me write a new SQLite recursive CTE that generates a Sierpinski triangle PNG using the same approach as sqlite-creative-coding
Prompt 3
Show me how to run the Voronoi diagram example using sqlite-creative-coding's justfile and save the output as a PNG
Prompt 4
Explain how sqlite-creative-coding pipes SQLite output through ImageMagick to assemble an animated GIF from per-frame pixel data
Open on GitHub → Explain another repo

← phenax on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.