For International Artist Day I wanted to hang code on a museum wall, as paintings that the code itself had made.
The result is Oil on Silicon: six famous programs, from Euclid's algorithm to the fast inverse square root in Quake III, each turned into an oil painting by its own source. There's also a studio where you can paste your own code and get a painting back.
Live: https://swastik21.github.io/oil-on-silicon/
Source: https://github.com/swastik21/oil-on-silicon
It's plain JavaScript and a canvas. No libraries, no server, no build step. Here's how a program becomes a painting.
Step 1: read the code like a highlighter would
The first job is to cut the code into tokens and give each one a kind: keyword, function, type, string, name, number, operator, comment or bracket.
The tokenizer doesn't really understand any language. It walks through the text one character at a time and makes a reasonable guess. A word followed by an opening bracket is a function. A word in capitals is a constant.…