art.generative
pictures grown from simple rules: fractals, cellular automata, the Game of Life, mazes, starfields
Pictures that grow from a few simple rules. Give a size and sometimes a seed, and get back a fractal, a cellular automaton, a Game of Life board, a maze or a starfield, drawn as text.
Tags: art
lsystemgrow and draw an L-systemfractaldraw a well-known fractal by namerulerun a cellular automatonspiralan Ulam spiral: the numbers 1, 2, 3, … wound outward from the center, with a dot for each primestarfielda random night skymandelbrotthe Mandelbrot set, the famous fractal, drawn in ASCII charactersliferun Conway’s Game of Life for steps generations and draw the live cellsmazea random maze with exactly one path between any two points
Functions
Section titled “Functions”lsystem
Section titled “lsystem”lsystem(axiom: str, rules: map, angle: num, n: int, width: int = 60) -> str
grow and draw an L-system
Start from the axiom string and rewrite it n times, replacing each character that has a rule (a map from a character to its replacement). Then draw the result in braille dots, width characters wide, with a pen that starts facing up: F and G draw a step, f moves a step without drawing, + and - turn by angle degrees, | turns around, [ saves the pen’s place and ] goes back to it. Other characters do nothing
1lsystem("F", {F: "F+F-F-F+F"}, 90, 3, 30) ⡤⠇
⣀⡏⣏⡇
⢀⣀⣖⡃
⢀⣰⠚ ⠓⣗⣆⣖⡆
⢰⢺⢲ ⡖⡗⡗⡆
⢠⠼⠉⠈⠉ ⠉⠁⠉⠁
⡤⠏⠹⠽
⣏⡁
⠓⣆⣰⣲
⠘⢲⣀⢀⣀ ⣀⡀⣀⡀
⠸⢼⠼ ⠧⡧⡧⠇
⠈⠹⢤ ⡤⡯⠏⠯⠇
⠈⠉⠯⡅
⠉⣇⣏⡇
⠓⡆See also fractal
fractal
Section titled “fractal”fractal(name: str, n?: int, width: int = 60) -> str / fractal() -> list
draw a well-known fractal by name
The names are “dragon”, “koch”, “hilbert”, “sierpinski”, “levy”, “gosper”, “tree”, “fern” and “bush”. n is how many times to rewrite, so higher is more detailed (each fractal has its own usual depth), and width is as for lsystem. With no name, the list of names
1fractal("koch", 3, 30) ⡀⠠⡴⢧⠄⢀
⠐⡞⠑⠚ ⠓⠊⢓⡆
⣀⣠⣀ ⢈⣙⠄ ⠠⣋⡁ ⣀⣠⣀
⣀⡴⣀⡕ ⢪⣀⢦⣀⠇ ⠐⣅⡴⣀⡕ ⢪⣀⢦⣀
⠯⡄ ⢠⠽
⢖⠋ ⠙⡲
⠓⠲⠒⡢ ⢔⠒⠖⠚
⣉⡧ ⠰⣉
⡤⠴⠤⠕ ⠪⠤⠦⢤
⠮⣄ ⣠⠵
⣖⠃ ⠘⣲
⠉⠳⠉⡣ ⢜⠉⠞⠉⡆ ⠠⡋⠳⠉⡣ ⢜⠉⠞⠉
⠉⠙⠉ ⢈⣩⠂ ⠐⣍⡁ ⠉⠙⠉
⠠⢧⡠⢤ ⡤⢄⡬⠇
⠁⠐⠳⡞⠂⠈2fractal()["dragon", "koch", "hilbert", "sierpinski", "levy", "gosper", "tree", "fern", "bush"]rule(n: int, width: int = 64, steps?: int) -> str
run a cellular automaton
A row of cells, each on or off, where each new row follows from the one above by the rule numbered n (0-255). It starts from a single live cell in a row width cells wide whose ends wrap around. Draws steps rows (half the width without steps), two rows per line of text
1rule(30, 32) ▄█▄
▄█▀▄▄█▄
▄█▀▄▄█▄ ▄█▄
▄█▀▄▄█▄ ▄█▄▄█▄
▄█▀▄▄█▄ ▄█▀▀▄ ▄█▄
▄█▀▄▄█▄ ▄█ █▀▀▀ █▀▄▄█▄
▄█▀▄▄█▄ ▄█▀▀▄▄█▀▄▄█▀ █▄ ▄█▄
▄█▀▄▄█▄ ▄█ █▀▀▄ ▄█▄▄█▀▀▄▄█▄▄█▄2rule(90, 32, 16) ▄▀▄
▄▀▄ ▄▀▄
▄▀▄ ▄▀▄
▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄
▄▀▄ ▄▀▄
▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄
▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄
▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄spiral
Section titled “spiral”spiral(size: int = 40) -> str
an Ulam spiral: the numbers 1, 2, 3, … wound outward from the center, with a dot for each prime
The primes mysteriously line up along diagonals. size characters wide
1spiral(20)⢀⠄⠁⢐⢄⠄⠐ ⠔⠑⠄⠕ ⢁ ⠁⢐
⢀⠄ ⢀⠁⢁ ⠁⠔⠁⢔⢐ ⠐⢄⠁⠄⠄⠁
⠐⠑⢄⠁⢁⠄ ⠕⠁⢀ ⢅⢀⠐⢅⢐⢀ ⠐⠐
⢀⠁⢁⠐⢀ ⢑⢀⠐⢑⠄⠄ ⢀⠅⢁⢄⠑⠄⠄
⠐⠄⠄⠄⠔⠄⠔⠔⢄⢁⢕⠐⠑ ⠄⠐⢐⠐
⢀⠐⢀⢀ ⢑⢔⠑⢌⠁⢁⢁⠁⢀⠁⢁⢁
⢀⢅ ⢁ ⢅⠄⠑ ⠄⠁⢄ ⠕⠁⢀⠁⠄⢄
⠅⢄⠄⢅ ⠐⠑ ⠕⢅⢀⠐⠄⠐ ⠄⠔
⠑⠐⠁⠁⢀⠐⢅⠄ ⢅⠔⠁⢁ ⠐⠄ ⢐⢅
⢐ ⢐⢀⠁⢁⠐ ⢁ ⠐ ⢐⠄ ⠑⠄See also is_prime
starfield
Section titled “starfield”starfield(width: int, height: int, seed?: int) -> str
a random night sky
Give the same seed to get the same sky again
1starfield(30, 4, 7) .
· ·
· · + +
. ·See also negative
mandelbrot
Section titled “mandelbrot”mandelbrot(width: int = 72, height: int = 24) -> str
the Mandelbrot set, the famous fractal, drawn in ASCII characters
1mandelbrot(40, 12)
...:
...:@@@..
..#+=@@@@@@@:#:.
.........#@@@@@@@@@@@@-.
..:@@@@@:@@@@@@@@@@@@@@@-
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-..
..:@@@@@:@@@@@@@@@@@@@@@-
.........#@@@@@@@@@@@@-.
..#+=@@@@@@@:#:.
...:@@@..
...:See also life
life(start: str, steps: int = 1, wrap: bool = false) -> str
run Conway’s Game of Life for steps generations and draw the live cells
On a grid, a live cell survives with 2 or 3 live neighbours, and an empty cell comes alive with exactly 3. start is a picture with # for live cells and . for empty ones, or a named pattern: “glider”, “blinker”, “pulsar” or “r_pentomino”. The board grows as needed, unless wrap is true: then it stays start’s size and cells leaving one edge come back on the other
1life("blinker")#
#
#2life("glider", 4).#.
..#
###See also maze
maze(width: int = 20, height: int = 10) -> str
a random maze with exactly one path between any two points
1maze(6, 3)██ ██████████████████████
██ ██ ██
██████████ ██ ██████████
██ ██ ██
██ ██████████████████ ██
██ ██
██████████████████████ ██See also life
More examples
Section titled “More examples”grow things
Section titled “grow things”1# a dragon curve2fractal("dragon", 8, 30) ⣀⣸⣉⡇ ⢀⣸⣉⡇
⠓⢺⠒⡆⡖⢺⢺⠒⡆⡖⠂
⠸⠭⡧⠏⠹⢤ ⢠⢤ ⠯⢽⠭⡯⡅⠈⠉ ⠉⠯⠅
⣖⣲⣰⣒⡃ ⠐⠚ ⣖⣺⣚ ⣀⣖⣚ ⠓⠃ ⣆⡖⠂
⠸⢼⠤⠇ ⡤⢼⢼⠤⡧⡧⢼⠤⡄
⣀⣀⢘⣒⣆⣖⣲ ⣀⣰⣲ ⣓⣺⣺⣒⣗⣗⣺⠒⣗⡆
⠧⢼⢼⠤⡧⡧⢤⢠⠤⡧⢼⢤ ⡤⡧⢼⢼⠤⡧⡧⢤
⠈⠉ ⠉⠁⠈⢹⣉⣏⣹⣹⣉⡁⠉⠉⠈⠉⣏⣏⣹⣉⣇⡀
⡖⢲⢰⠒⡗⠚⠘⠒⠃ ⢰⢲ ⡖⡗⠚ ⠓⠃
⠉⠹⠽⠉⠯⠽ ⠈⠹⠭⠏⠯⠽3# a tree in a box4fractal("tree", 6, 24).boxed("round")╭───────────────────╮
│ ⢀⡀⠐⢾ ⡯⠂ ⠐⠪⡇⡹⠒ ⣀ │
│ ⣀⠓⣇ ⢹ ⢹⠁ ⢀⠗⢃ │
│ ⠞⠉⠉⠑⠤⣸ ⢸⡠⠔⠉⠉⠱ │
│ ⠘⢆ ⢀⠎ │
│ ⠈⢢ ⣠⠃ │
│ ⢳⠃ │
│ ⢸ │
│ ⢸ │
│ ⢸ │
│ ⢸ │
│ ⢸ │
│ ⢸ │
╰───────────────────╯5# Sierpinski's triangle, two ways6rule(90, 32, 16).beside(fractal("sierpinski", 4, 16), 4) ▄▀▄ ⣰⣇
▄▀▄ ▄▀▄ ⣼⣷⣾⣧
▄▀▄ ▄▀▄ ⢀⡾⢿⡄⢠⡿⢷⡀
▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄ ⢠⣞⠛⠚⠛⠛⠓⠛⣳⡄
▄▀▄ ▄▀▄ ⣠⣿⣻⣦ ⣴⣟⣿⣄
▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄ ⣰⣯⡉⠉⣹⣧⡀⢀⣼⣏⠉⢉⣽⣆
▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄ ⠼⠷⠼⠷⠼⠷⠼⠷⠾⠧⠾⠧⠾⠧⠾⠧
▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄ ▄▀▄7# a plant from your own rules8lsystem("X", {X: "F[-X][X]F[-X]+FX", F: "FF"}, 25, 4, 30)⣀⡀⠐⣄⡀ ⠈⢧ ⡄
⠈⠉⠙⠳⡀ ⠈⢷⡇ ⠒⡄⢀
⠈⠲⣄⢻⢆⣜ ⠸⣸
⠹⣿⠎ ⡟ ⢰
⡀⠹⣀ ⠢⡌⣇ ⢠⣏⡄
⠉⠓⢵⣇ ⠠⡸⣿⣜⠟⡉
⢻ ⣷⣿⡿⠊⢱
⠈⢣ ⣬⡿⡇ ⢠⣏⡀
⢣⡇⣧⣏⣼⡟⠋
⢸⡝⢺⣵⣿⠖⠁
⢸⢠⠋
⢸⠃
⢸
⢸
⢸9# the Mandelbrot set10mandelbrot()
.-.
.......
...-=:...
.....:@@@@@:..
.........:@@@@+:.........
....:@@:%@@@@@@@@@@@@@:.:::#.
.....*.#@@@@@@@@@@@@@@@@@@@@@:..
................-@@@@@@@@@@@@@@@@@@@@@@@=...
....:@-.:@::...:=@@@@@@@@@@@@@@@@@@@@@@@@@-..
...:.-@@@@@@@@=:-@@@@@@@@@@@@@@@@@@@@@@@@@@@-.
........#=:+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+:...
........#=:+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.
...:.-@@@@@@@@=:-@@@@@@@@@@@@@@@@@@@@@@@@@@@-.
....:@-.:@::...:=@@@@@@@@@@@@@@@@@@@@@@@@@-..
................-@@@@@@@@@@@@@@@@@@@@@@@=...
.....*.#@@@@@@@@@@@@@@@@@@@@@:..
....:@@:%@@@@@@@@@@@@@:.:::#.
.........:@@@@+:.........
.....:@@@@@:..
...-=:...
.......
.-.11# a glider, 8 steps on12life("glider", 8).#.
..#
###13# start from your own pattern14life(".#.\n.#.\n.#.", 1)"###"15# a maze16maze(12, 6)██ ██████████████████████████████████████████████
██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██████████ ██ ██████████
██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██████████████████████ ██ ██████████ ██
██ ██ ██ ██ ██
██████████ ██████ ██ ██ ██████████████████ ██
██ ██ ██ ██ ██ ██
██ ██████ ██ ██████████ ██ ██████████████████
██ ██ ██ ██ ██ ██ ██
██ ██ ██████ ██ ██ ██████████████████████ ██
██ ██ ██ ██
██████████████████████████████████████████████ ██Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.