Curves

Flow lines

Evenly spaced streamlines of a vector field after Jobard and Lefer: swirling noise, whirlpools, dipole field lines — as if drawn by a pen plotter.

  • vector geometry
  • seamless tile
  • looping animation
  • SVG export
Open in the editor →

Streamlines show where a fluid flows, field lines where a force pulls. They trace the wind on weather maps and the field of a magnet revealed by iron filings. Generative art has made a genre of them: hundreds of smooth lines running side by side, never crossing or bunching up, perfect work for a pen plotter.

How it works

It takes a field and a way to lay lines on it. The “curl noise” field takes a smooth noise ψ(x, y) and turns its gradient by 90°. Such a field has zero divergence: no sources or sinks, a “fluid” that neither compresses nor expands, and streamlines that coincide with the contour lines of ψ, so the flow goes round the hills of the noise like contours on a map. In “noise angles” the noise value simply sets the arrow's angle, and lines may converge. The “vortices” field holds point whirlpools, and “dipoles” pairs of opposite charges whose field lines look like those of small magnets.

v = (∂ψ/∂y, −∂ψ/∂x), div v = 0, v ⟂ ∇ψ step: x ← x + h · v̂(x + ½h · v̂(x)) a new line starts d_sep from an old one; it stops closer than d_test

The lines are laid out by the Jobard–Lefer algorithm. The first grows from a random point both ways, stepping along the field by the midpoint method. Along every finished line, seeds for new ones are placed d_sep away (“Line spacing”) on both sides. A growing line stops as soon as it comes closer than d_test (“Closeness”, a share of d_sep) to any other.

A bit of history

Bruno Jobard and Wilfrid Lefer published the algorithm in 1997 for scientific visualisation, where randomly seeded lines clump, leave holes and misrepresent the flow. Robert Bridson and colleagues invented curl noise in 2007 for smoke and dust in films: it is cheap and looks like a real incompressible fluid. The noise here is periodic, Stefan Gustavson and Ian McEwan's psrdnoise, so in tile mode the lines pass through the edges without a seam. In the animation the field does not slide: its gradients rotate in place, so the swirls churn without drifting, a trick Ken Perlin and Fabrice Neyret called flow noise in 2001.

What to tweak

  • A “Taper” of 0 gives even lines of one width: export an SVG for a plotter.
  • Lower “Closeness” to 0.2 and lines come almost into contact and grow long; near 1 they stop early and the pattern turns into hatching.
  • “Field” set to “dipoles” with a “Scale” around 1 is straight from a physics textbook; “vortices” gives closed rings round the whirlpool centres.
  • Three or four “Octaves” add small swirls on top of large ones, like marbled paper.
  • Put the “Wallpaper symmetry” effect on top and the flow folds into a repeating ornament, like printed fabric.

Parameters

Field
curl noise · noise angles · vortices · dipoles
Scale
Noise frequency, or how many vortices and dipoles
Octaves
Small swirls on top of large ones
Line spacing
Closeness
How close a line may come to its neighbour, as a share of the spacing
Integration step
As a share of the line spacing
Line length
The longest a single line may grow
Weight
Line width as a share of the spacing
Taper
Lines thin towards their ends; 0 gives even lines for a plotter
Colouring
one colour · by direction · by length · in patches
Line colour
Speed
Turns of the field per animation loop