Menu

How I painted famous programs with their own source
📰

How I painted famous programs with their own source

DEV Community: webdev·swastik poojari·5 days ago
#GIWGAA5B
#devtowebdev#devto#dev#include#oilonsilicon
Reading 0:00
15s threshold

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

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.