🎓 Classes using marimo.

Browse classes
113 / 113
Unbroken Line

Unbroken Line

by Simone Multari

Draw a painting with one line that grows, folds, and never crosses itself.

About this notebook

This notebook draws a painting with one closed line that grows from a small ring and never crosses itself. The line packs tight where the picture is dark and stays open where it is light. The notebook includes five paintings: the Mona Lisa, Girl with a Pearl Earring, Lady with an Ermine, Caravaggio's Medusa, and The Creation of Adam. The method follows the labyrinth growth of Pedersen and Singh (NPAR 2006). The code uses NumPy, SciPy, Pillow, matplotlib, and numba.

Select a painting from the dropdown, or upload your own picture. For three paintings, the notebook loads a precomputed growth, and a growth slider shows each stage of it. Sliders for r min, r max, gamma, local contrast, blur, and start x and y change the spacing map, and three panels show the result. To grow the line yourself, set the width and the maximum steps, press "grow", and use the snapshot slider to view each stage. The "How it works" sections explain the method one idea at a time, with a slider for the Lennard-Jones curve. There, f_B, f_F, and f_A sliders control a ring that grows on blank paper, and the notebook plots the point count and counts the crossings.

Each step moves every point by a random tremble, a pull toward its two neighbors, and a Lennard-Jones push and pull from nearby strands. The notebook then splits long segments and removes points that sit too close together. After every step, a check returns each segment that crosses or touches another strand to its previous position. numba kernels on a uniform grid compute the forces and the check. In the browser, numba is not available, so the notebook uses NumPy and SciPy KD-tree code and shows a note in place of the painting grow button. The palette follows the page theme.

Related notebooks