Kurbits

A mathematical ornament machine
Motion
Colour
Point in the space
Four numbers draw everything.
These numbers

Presets

How it is built

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.

1Where x, y and z go

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.

The wave for setting k. Its direction and offset come from k and the golden angle g ≈ 2.40, which spreads the thirty waves evenly.
The setting’s range and a threshold. Below t (zero for most settings) the setting rests at lo, so some features, such as pen loops, exist only in parts of the space.
Applied to the two turn angles: a dead zone around zero, so a turn fades in from nothing instead of every stroke having one.
Turns the mirror setting into how strongly the ornament is doubled by its mirror image.
Clamped to lie between 0 and 1.

2What detail does

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.

A smooth step, rising from 0 at a to 1 at b. Most of what detail does fades in this way, so detail sweeps without jumps.
How many sprouts grow on each stroke, and how many generations deep the branching goes. Fractions are allowed: the last sprout or generation grows in gradually.
Self-similarity, which begins above d = 0.55. At 1, every sprout is an exact small copy of its parent, turned and mirrored: a true fractal.
How much each sprout and scroll differs from its neighbours.
How far the curls at the two ends of the stroke grow (layer 6).
Above d = 0.4 the main stroke sways a little more, gains small pen loops and turns more sharply.

3Settings become symbols

The settings are named for what they do. Here they are translated into the symbols that the formulas in the following layers use.

Settings from layer 1. Among them, at is where along a stroke the sprouts start, length how long they are, and straight how little they curl.
The length of the spiral eyes, fixed at 1.
The pen’s weight and contrast, fixed at 0.4 and 0.8.
Self-similarity, from layer 2.

4One stroke

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 sway: the stroke swings from side to side. A is how far, f = 0.6 how often, and φ where along the stroke.
A sharper, meandering sway (the Kinoshita curve). The engine supports it, but here flat and skew are always 0.
The Euler bend: the curvature changes steadily along the stroke, so it tightens or opens like a clothoid.
A constant turn. It is zero unless the curls have grown (layer 6).
Soft changes of direction. Each step turns the pen by a, spread over a stretch of width σ around the place μ. There are three turns, whose angle, place and width are settings, and m pen loops, which are full turns placed as the next two formulas show.
Where the i-th pen loop sits and how far it turns: 2πT·rⁱ, with the direction alternating by the amount alt. Here T = 1, r = 0.8 and alt = 0.5. A fractional m grows the last loop in.
The spiral eyes at the start and at the end: n is how many turns, c the fraction of the stroke they are wound into.
The shape of the spirals, a log-aesthetic curve. β sets how quickly a spiral tightens towards its centre, and ε = 0.01 stops it from winding infinitely tight.
The stroke’s position. The engine adds up a few hundred small steps (the trapezoid rule).

5The pen

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.

The direction of travel, the hairline width, and the slant of the nib (s = 0.25).
v is the position along the stroke, and r the pressure: 0.5 for main strokes and 0.75 for sprouts. The pressure blends the swelling shape towards a comma, heavy at the start.
Three width profiles: thickest in the middle; heavy at the start and tapering away; heavy towards the end.
Thin the line inside the spirals, where the turns are tight.

6Growing curls

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 new lengths of the start and end curls. Only curls that exist grow: the smooth step on |n₀| or |curl| is zero for a stroke without one.
How many times longer the stroke becomes, and where its old start now lies.
The sway and the Euler bend, rewritten so that the body keeps its shape; the bend gains the constant turn κ.
The same for the place and width of each turn.
The curls wind further: to at least 1.6 turns at the start and 2.1 at the end.
The limbs’ end curls grow the same way, to at least 1.6 turns, wound into up to 62% of the limb.

7The recursive rule

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:

  1. It grows sprout count(k) sprouts. Their growth is weighted by grown(k), so a fractional depth fades the last generation in.
  2. Sprout j sits at u = place(j, n) along the stroke, where n is the sprout count, and leans away from it at the angle sprout angle(j, v), alternating sides.
  3. Its size is s × sprout size(u, t), so sprouts get smaller towards the tip, times a weight that fades in the last, fractional sprout.
  4. It curls into an eye of sprout curl(n, dir, v) turns, where n is the parent’s end curl and dir is +1 or −1 for the side it grows on.
  5. A sprout smaller than smin, measured as a fraction of the main stroke, is not drawn, and one just above it is shrunk by lowpass. Detail therefore fades out instead of turning into fuzz.
  6. Its line is w₀ × s × line width(k, rel) wide, where rel is its size relative to the main stroke. With ω = 1 the line shrinks in proportion to the sprout; as self-similarity lowers ω towards 0.4, small sprouts keep bolder lines. Each generation is also η times thinner.
  7. With self-similarity χ, each of its symbols is mixed towards its parent’s: mix(sprout, parent, χ). At χ = 1 the sprout is an exact small copy of its parent.
The elegance, fixed at 0.6.
The budget, between 0 and 1: close to 1 for a sparse ornament, smaller for a busy one.
The requested proportions (aspect and 1). Wide ornaments get a slightly finer pen.
Small, fixed variations: v is Q evaluated at a point that depends on the sprout and its generation, and t is such a point. Q adds three sine waves whose frequencies never line up, so the pattern never repeats.
How much sprouts vary (0.25), and how much they shrink towards the tip of their parent (0.35).
Every sprout curls at least 1.1 turns.
Settings from layer 1: which side the sprouts grow on (−1 one side, 0 alternating, +1 the other), and whether they spread along the stroke or fan out from one point.

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.