Four numbers go in: x, y, z and detail. Aspect only sets the proportions. An ornament comes out. In between are seven layers, described below with the exact formulas the engine runs. The page prints them from the same definitions the program compiles, so the two cannot disagree. Nothing is random: the same numbers always draw the same ornament, and every number can be swept smoothly.
An ornament is described by about thirty settings: how tightly the stroke curls, how much it sways, where it turns, how long its sprouts are, whether it is mirrored, and so on. x, y and z do not appear in the curve itself. Instead, each setting is read off a slow wave that runs through the space.
Setting number k has its own wave, osc(x, y, z, k), which rises and falls between 0 and 1. The waves all point in different directions, so moving through the space mixes the settings in ever-new combinations without repeating. The value of the wave is then stretched to the setting’s own range.
Detail d runs from 0 to 1. It hardly changes the main stroke; mostly it decides how much grows on it. The functions below turn d into the number of sprouts, the number of generations they branch into, and how closely each sprout copies its parent. The last four also take the value that x, y and z gave a setting, and only ever strengthen it.
The settings are named for what they do. Here they are translated into the symbols that the formulas in the following layers use.
Every mark in the ornament, large or small, is the same kind of curve, described by its direction rather than its position. u is a single number that runs along the stroke, from 0 at its start to 1 at its end, and θ(u) is the direction the pen is heading at that point, as an angle.
To draw the stroke, the pen keeps stepping forward in the direction θ(u); x(u) and y(u) add up those steps. So the formula for θ says how the pen turns, and the shape follows from it.
The stroke is inked like a pointed pen. Its width at each point is the product of three factors: a base width w₀, scaled to the size of the stroke; the taper, which shapes the width along the stroke and thins it inside the spiral eyes; and the pen, which swells on down-strokes and thins to a hairline on up-strokes.
As detail rises, through F = flourish(d), the curls at both ends of the stroke grow longer and wind further, while the middle of the stroke, its body, keeps exactly its shape. The start curl grows to the length T₀ and the end curl to T₁, both measured as fractions of the original stroke; the body keeps its length. The stroke therefore becomes Λ times longer.
In the longer stroke the body sits on a different stretch of u, so every symbol of θ is rewritten for the substitution u = δ + Λu′. The rewritten symbols, marked with a prime, replace the originals. The root of the stroke is also turned and moved, so that the body stays exactly where it was.
The ornament is built by one rule applied again and again. Along every stroke, smaller strokes grow, the sprouts, and each sprout grows sprouts of its own, down to the depth D. The main stroke is generation 0, its sprouts are generation 1, and so on.
First an elegance budget trims the detail, so that the ornament never becomes crowded: the more sprouts and generations there are, the more they are all cut back. The weight exponent ω is also set here, from self-similarity (see step 6).
Then, for each stroke of generation k and size s:
A few things are done by the program rather than by a formula. A sprout attaches at the edge of its parent’s line, on the side it leans towards. Variation also moves each sprout’s settings a little in a fixed direction through the settings. The mirror image, an answering curve and up to two limbs grow from the same root as the main stroke. Aspect is met by adding chained scrolls: the program searches for the number of scrolls that gives the requested ratio of width to height. Finally, the line width is adjusted by measuring how much of the ornament’s area is ink, so that dense ornaments are drawn with a finer pen.
Leaves imports leaves.js, which a page opened as a file cannot do: serve the folder (python3 -m http.server) and open it from there.
Kurbits Leaves is a second engine, after Dalecarlian kurbits painting (dalmålning, about 1780 to 1870). Like the Machine it is one recursive rule applied over and over: a shoot (a stalk, then a head of brush strokes) grows smaller shoots from behind itself, along its length and from behind its head, and they grow smaller ones, down to the depth that detail sets. Nine numbers go in, and every one is continuous. x, y and z choose the composition: how many shoots spring from the root and where they head, how they bend, where along them their sprouts come out, how far their heads have opened into flowers, and whether the design is mirrored. Detail is the depth, plump, lobes and curl shape the leaf, variation is how much each leaf differs from the next (every shoot and every stroke of a head is an instance of its own, so no two are alike), and aspect sets the proportions: wider, a frieze, a scroll that swings out to both sides of the motif, mirror-symmetric about it in most of the space, with plants standing and hanging in its bays, feature motifs among small sprigs, lush stretches and open ground, and plants that change gradually along its length, up to dividers some twenty to sixty times as long as they are tall. Every point draws a design, and a small step in any number changes it only a little: whatever appears, a generation, a shoot, a finger, a petal, a stripe or a repeat, grows from nothing. Nothing is random either: the same numbers always draw the same design.
What it takes from the paintings. The references are two pictures on Wikimedia Commons: an anonymous bonad of 1799 with the ages of life on a stepped arch, framed by two tall plants, and Back Olof Andersson’s painting of 1808 with two riders, a stacked plant between them and a border along the bottom. Looked at closely, a kurbits leaf is not a botanical leaf at all but a single brush stroke: a thick band that comes out broad from behind a flower or another leaf, swells, arches over like a horn or a breaking wave, often through more than a right angle, and tapers to a sharp point that hooks back, sometimes ending in a hair-fine curl. It has no stalk and no pointed blade. Inside, it is striped along its length, three to six stripes that follow its curve and run together at the tip. Fan several such strokes out from one point and they become a cluster of hooked fingers; make them shorter, broader and rounder and they become the spoon-shaped fan of the 1808 plant, striped from its base to its scalloped edge. Close the fan into a full ring and it is a rosette, the round flower of rings of scalloped petals round a centre that nestles among the horns in 1799 and sits in every bay of the 1808 border; cup a few petals together and it is a tulip. Leaves come out everywhere, not at one place on a stem: in pairs and whorls along the whole stem, from behind other leaves, stacked one behind another in a plume that arches all one way, fanning out from behind a flower, arching outwards and down from the top of a plant. The painters swelled and thinned every stroke, and flicked fans of hairlines from the outer side of a bend. The 1808 border is a running scroll: one swelling stroke swings from the bottom of the band to the top and back, each half-wave winding into a tight volute at its end while the next springs from its flank, a rosette with its leaves sits in every bay, and fans of hairlines spring where the strokes meet; the ground between stays open. This engine keeps to leaves, stalks and flowers, in line: no vases.
About forty settings describe a composition: where the main shoots head and how many there are, how far they bend, how much of them is stalk, how many sprouts each shoot grows, where along it, how large and on which side, whether they curl with their parent, how far the heads open into flowers and what kind, and so on. As in the Machine, x, y and z do not appear in the drawing. Setting k is read off a slow wave Wk through the space, each wave in its own direction (the golden angle g spreads them), and stretched to the setting’s range. The mirror is read off its wave turned over, steeply, so that most of the space is mirrored and some of it not, with a gentle passage between. A budget then trims the sprouts so that a design never crowds. The side bias is read off its wave so that it is zero in most of the space and rises smoothly only towards either end, and the symmetry, how exactly a mirrored twin mirrors (layer 7), is exactly 1 in most of the space. Further settings are how far every instance varies (vary, layer 6), how far a frieze’s scroll swings and how strongly its rhythm of feature motifs, sprigs, lush and open stretches runs (layer 8), and wander, how far the repeats of a frieze or a tower wander from the motif (layer 9).
Every stroke, large or small, is built along its spine, a curve described by its curvature κ(u), as every stroke of the Machine is described by its direction. u runs from 0 at the base to 1 at the tip. The spine arches, more and more tightly towards the tip (an S reverses the arch near the base), then hooks: the tip winds n times round with a radius that shrinks with the length left, like a logarithmic spiral. The band ends at 1 − τ; past it the tip winds on as a hairline. c, from −1 to 1, is the stroke’s chirality, the way it arches. At c = 0 the stroke is straight and symmetric, which lets it turn from one way to the other without a jump; c′ rises steeply from 0, so that few strokes are nearly straight.
On each side s of the spine the edge lies ws from it: the stroke’s length times its width w, times an envelope E. The band comes out broad (b0 of its full width), swells to its widest at v*, then either tapers to a sharp point (ρ = 0, a horn) or closes in a round end (ρ = 1, a petal or a lobe of a fan); every shape between is a blend of the two. The convex side, away from the arch (o = 1), swells further by a. A stroke on a stalk, or one coming out of something narrower than itself, flares out of a neck instead (ν), so it never shows a cut base; one coming out from behind a broad leaf or a flower starts broad, its base hidden.
The band is striped. Stripe j lies at the share fj of the band’s width, evenly spaced but pushed towards the convex side, so the stripes crowd along the outer edge as the painted ones do. Its distance from the spine is a share of the width, so the stripes run together at the tip and at the neck. A stripe is drawn only where it is a line and a gap clear of its neighbours, and its ends are found between samples, so they move smoothly; a fractional count grows the last stripe back from the tip. The outline is drawn as a brush would draw it: thickest along the convex side’s belly, fine at the tip, and each stripe swells in its middle and thins at its ends. A band too narrow to read as one fades into a single hairline along its spine, so the youngest sprouts are tendrils, and the hairline past the band tapers to nothing.
At the end of each shoot’s stalk sits its head: m strokes fanned out from one point, δ apart, the last, fractional one growing in. In a leaf the fan is one-sided: each further stroke turns towards the concave side of the first and is shorter by ρf, so one stroke is a horn, three are a cluster of hooked fingers, and six short, round-ended ones a fan. In a flower the fan is centred, alternating left and right of the first, and each stroke curls outwards (a palmette) or, cupping, inwards (a tulip). Lobes runs the leaf from horn to fan. How far a head has opened, b, runs it from leaf to flower: every number of the head is blended from the leaf’s to the flower’s by a smooth step of its own, so a fan’s strokes first shorten and round off, then multiply and close into a ring, and rings of smaller petals and a round centre grow in inside it. The flower’s own number, cup, runs from an open rosette of twelve petals in rings to a tulip of three cupped petals. On a straight shoot, with no concave side, the fan is centred. Every stroke is an instance of its own: its angle (except the first, the shoot’s own spine), length, width, arch and hook are moved a little by the instance variation at its place in the head (layer 6), and each inner ring its size and turn, so no two strokes of a head, and no two petals, are alike.
Each shoot of generation k grows sprouts, generation k + 1, and they grow sprouts of their own. Detail d sets the depth D = 3d: generation k is weighted by [D − k + 1], so each third of the detail slider grows one more generation in from nothing. A new generation first appears as tendrils, which fill out into leaves as the depth rises further; deeper generations stay slimmer by λk. Sprouts come out all along a shoot, not at one place: each shoot has its own stretch, from ua to ue (the settings from and to, each moved by the shoot’s own Q), and its own phase φ, which slides the sprouts along it, so they sit in different places on different shoots and in different generations. They alternate sides along the shoot, each shoot beginning on a side of its own, or come in pairs at nodes (pair), staggered or not (alt), with a second, rising sprout at a node (a whorl); a bias can move them to the convex or the concave side, but in most of the space there is none, so as many leaves come out on one side of a stem as on the other; and a cluster fans out from behind each head, from leaning out to hanging, so a flower is ringed with leaves that arch outwards and down. A sprout curls the way it leans, or, nested, the way its parent curls, so the leaves stack one behind another in a plume. From the outer side of a bend a fan of hairlines springs. Every shoot is an instance of its own, as every scroll and sprout is in the Machine: two directions D1 and D2 through about twenty shape numbers (how far its sprouts lean, their size, curl and number, where they come out and on which side, its stalk, its clusters and hairlines, the leaf’s plumpness, lobes, curl and stripes, the flower’s cup), set by the settings varAngle and varTwist, span a plane, and each shoot sits at its own quasi-periodic point of it, so no two leaves or heads are alike, while the same numbers always give the same shoots.
Up to 3.4 main shoots spring from the root, the first heading at the angle turn from straight up towards the right and each further one spread further round; a fractional count grows the last one in. A smooth minimum keeps the fan short of straight down, so a mirrored design never crosses its axis. A main shoot curls outwards, away from the axis, by bend times the cosine of its heading, so one heading down curls the other way round and one heading sideways not at all, and by arch times its sine, up into an arch or a wreath, or down into a swag. Its head opens by bloom times tips. In a mirrored design an upright crown, a straight symmetric shoot whose head is a centred fan (a fleur-de-lis, or, opened, a tulip or a rosette), rises on the axis, and the mirror image (x → −x), m times the size, grows from the same root: of the same shoots where the symmetry is 1, so the design is exactly symmetric, its sprouts and their sides included; where it is lower, as in the Machine, of a twin whose numbers drift away, each by (1 − symmetry) times its amplitude times sin(asymPhase + i g), and its small variations with them, while the crown stays exactly symmetric. Heading up gives plants, bouquets and trees, sideways garlands, arches and lyres, down fountains; without the mirror, sprays, corner pieces and single sweeping stems.
Aspect is relative to the motif’s own proportions, as in the Machine: at 1 the motif stands alone. Wider, a frieze grows out of it to both sides, up to 48 times as wide as the motif, laid out as the border of 1808 is. The motif stands in the middle, mirrored (its mirror image grows in as the frieze does), and from behind it a scroll runs out to each side. The left half is the mirror image of the right half where the symmetry is 1 and of its twin where it is lower (layer 7), so most friezes are symmetric about their centre, and a longer frieze adds the same at both ends. Repeat j of a half stands in the scroll’s j-th bay: turned over when j is odd, so the plants stand in the troughs and hang from the crests in turn, above and below the scroll, and leaning with it as the setting lean says. The scroll passes each root at the phase jπ + θj, θj set by how upright the repeat stands, so an upright plant stands in a trough, a hanging one hangs from a crest, and one reaching sideways sits where the scroll crosses its axis. It is drawn one stroke to each half-wave, as a brush draws it: each stroke springs from behind the one before, a little before the node, swells through its crest or trough and, past the next node, winds into a volute in its own bay, a logarithmic spiral of 1.3 turns that thins to a point; at each node a fan of hairlines is flicked from the outer side of the stroke that goes on, and a short sprout curls into its bay, ending in a flower where the repeat’s flowers have opened. A rhythm runs outwards from the centre, the same on both sides: feature motifs, larger and opened into flowers ringed with horns or into large fans, among medium plants and small sprigs with fewer generations, by a quick Q along the repeats, and slow swells of lush clusters (closer, larger, with more sprouts) and sparse stretches of open ground, where the scroll runs long and swings wider, by a slow one. The scroll’s height wanders along the length as well. Repeats are spaced gap times the sum of their facing reaches, and a quarter more so that the plants sit in the bays, and added until the frieze is A times as wide as the motif; the last is weighted by the width still wanted, buds from the outer edge of the one before and moves out along the scroll while the scroll’s end runs on and its volute grows, so the design lengthens at an even rate and nothing further in moves. Taller, smaller tiers bud out of the motif’s top, each 0.84 times the one below and overlapping it by a quarter, up to eight: telescoping, as in a tall painted panel.
A frieze is not one drawing stamped again and again. Repeat j (0 is the motif, 1, 2, … outwards to the right, −1, −2, … to the left; for a tower, tier j) reads the same waves as the motif, each with its phase shifted by δk(|j|): a walk Δ along the repeats made of Q’s three sines whose frequencies never line up, zero at the motif, smooth, never repeating, and its own for each setting and each part of the space. So neighbouring repeats are alike, and over the length the plants change gradually: how many shoots there are and where they head, how they bend, sway and arch, where their sprouts come out, how far their flowers have opened and what kind they are, and the leaf itself, its plumpness, lobes and curl. The amount a is read off a wave of its own, like every setting, times the variation slider; it is never zero, so every frieze changes along its length, gently in some parts of the space and boldly in others. It runs outwards from the centre, the same way on both sides, and repeat −j is the mirror image of repeat j: exactly where the symmetry is 1, and of its twin where it is lower, whose walk and numbers drift as a twin’s do (layer 7). A repeat depends only on its own place, never on how many repeats there are. The mirror, the gap and the swing do not wander: every repeat of a mirrored design is mirrored, and the repeats keep the motif’s spacing; the frieze’s own rhythm of features, sprigs, lush and open stretches is layer 8.
Everything is a pen line: outlines, stripes, hairlines, the two sides of each stalk and of the runner, the rings of a flower’s centre. A stalk too narrow to read as a band, because the pens are bolder than it is broad (in a long frieze, a small sprig or under a sprout’s flower), is a single line along its middle instead, the two crossfading, never a solid bar. Each stroke has a silhouette, its outline moved out by a narrow halo, at a depth: deeper generations lie behind shallower ones, the strokes of a head one behind another, a rosette’s inner rings in front of its outer ring and its centre in front of all, and a stroke’s tip in front of the stroke, so a tip that hooks back hides the band beneath it. The stalks lie behind all of them, as the stems do in the paintings, hidden behind what they carry: a stalk shows only between its parent and its head, enters the head at its base, and passes behind every leaf and flower it meets, except the sprouts that come out along it, which come out from behind it. A line further back is cut where it passes under a nearer silhouette, at a point found by bisection, so the cut moves smoothly; it stops a small gap short of the outline, as in an engraving. A piece of line is faded by its length, measured in widths of its own or of its shoot’s outline pen, whichever is the wider: shorter than five it is drawn thinner, and shorter than one it is left out, smoothly, so the short dashes a cut would leave, fine stripes and hairlines among them, shrink away instead of popping or lingering as dots. Only then is a swelling line cut into its pieces of one width, and neighbouring pieces within 8% of one width are drawn as one. Every stroke keeps its number of samples, and every end that lies between samples is interpolated, so nothing snaps from one sample to the next.
For a print at a small size, such as an engraving, min line and gap, in main-shoot lengths, set the narrowest line and the narrowest gap. Lines keep at least that width, halos and the spaces between stripes at least that gap, stripes that no longer fit give way, a band and its hairline switch rather than fade, and pieces too short to print are left out.