Day 19: When Art Meets Code – Mondrian with Perl and CSS Grid

Day 19: Mondrian compositions from Perl and CSS Grid. No JavaScript, canvas, or SVG. Structure as the medium. #100DayMapChallenge.
Day 19: Mondrian-style composition generated with Perl and CSS Grid - #100DayMapChallenge

Day 19. When art meets code 🎨💻

Piet Mondrian reduced visual language to primary colors, straight lines, and right angles. I wondered: what if code painted the same way?

This experiment generates Mondrian-style compositions using Perl and CSS Grid, with a strict constraint: no JavaScript, no canvas, no SVG. Just HTML5 and CSS.

CSS Grid turned out to be a perfect match for Mondrian’s aesthetic. Rectangular subdivisions, precise alignment, clean edges. Each colored block becomes a grid cell, black lines are grid gaps, and the composition emerges from structure rather than drawing.

I wrote a Perl script to generate random layouts through recursive subdivision, then output pure HTML with inline styles. CSS variables handle colors, grid areas handle composition, and calc() manages proportions. The result loads in about 3KB, works in every modern browser, and is fully readable by simply viewing the source.

Sometimes the simplest tool is the most powerful one.

Code: mondrian-html-only on GitHub

The project

PieceRole
ConstraintNo JS, no canvas, no SVG
PerlRecursive subdivision → random layouts
CSS GridCells = color blocks; gaps = black lines
OutputPure HTML + inline styles (~3KB)

Note from campaign draft (optional depth)

An earlier draft asked how much randomness you can add before balance breaks, and what rules make a composition feel “Mondrian.” Generative art here is translation: aesthetic principles into algorithms, not a replica of a painting.

How to follow


#100DayMapChallenge · Day 19/100 · Mondrian / Perl + CSS Grid · LinkedIn

Previous: Day 18: Clickable Bubbles – OSM

Next: Day 20: Charts Hairball

Leave a Reply

Your email address will not be published. Required fields are marked *