Start with one rectangle covering the whole canvas. At each step, pick a remaining rectangle and cut it in two — horizontally or vertically, at a random ratio. Repeat as many times as you like and the varying-sized rectangles settle into a grid; because the axis and ratio are random each time, the layout reads far more rhythmic than a regular grid. The same idea, under the name binary space partitioning (BSP), also drives game rendering and collision systems.
Fill only some cells with an accent colour and leave the rest as background, and the result reads like a Piet Mondrian composition or the asymmetric grids of Swiss-style posters. This demo picks one cell at a time on an interval and splits it further, so the layout starts sparse and gets progressively denser.
Use it for poster and thumbnail background composition, generating the skeleton of a responsive layout, or auto-placing placeholder blocks in a UI mockup.
When to use
Use it for poster/thumbnail composition or quickly generating several layout skeletons. Keep the fraction of coloured cells low to preserve the Mondrian feel.