stroke
A still plate. A short walk that keeps turning the same way is smoothed into one curling path. Sixteen brush sweeps are laid side by side along it, dark on one side and pale on the other, from one of four ramps. The outer streaks start late and end early, so both ends of the stroke break up the way bristles lift off.

| Source | Ships as | Gzipped | Target |
|---|---|---|---|
| 45 lines | 5,044 bytes | 2,414 bytes | svg |
// stroke: one broad stroke of a loaded brush, laid as many streaks side by side
plate(1920, 2400)
use colour v2, brush v2, spline v2
random layout, marks
// a ramp from dark to pale, one of four
let ramps = [#2a1214, #6e1f1d, #b8452c, #e8b07a, #1f1a14, #5b4630, #a8803f, #e6cf98,
#1b201a, #45533a, #8c9a6a, #dfe0c4, #24161f, #5e2f4a, #a85a6a, #ecc9b8]
let pick = layout.int(0 ..< 4) * 4
let ramp = [ramps[pick], ramps[pick + 1], ramps[pick + 2], ramps[pick + 3]]
// the gesture: long steps that keep turning the same way, a little more or less each time, so it curls
var at = vec(0, 0)
var heading = layout.float(0 ..< TAU)
let bend = layout.float(0.3 ..< 0.7) * (layout.chance(0.5) ? 1 : -1)
let walk = vec[]
var middle = vec(0, 0)
for step in 0 ..< 9 {
walk.add(at)
middle = middle + at / 9
heading += bend * layout.float(0.4 ..< 1.6)
at = at + polar(heading, 300)
}
// smoothed into one curve, and moved so that its middle sits near the middle of the plate
let path = spline.sample(walk, steps: 12)
let shift = vec(layout.float(860 ..< 1060), layout.float(1050 ..< 1350)) - middle
// bands side by side across the stroke, each its own sweep, dark on one side and pale on the other
let width = layout.float(380 ..< 680)
let bands = 16
background(#efe8dc)
for b in 0 ..< bands {
let side = (b / (bands - 1) - 0.5) * width
// the outer bristles lift off sooner, so the edges of the stroke start late and end early
let edge = abs(b / (bands - 1) - 0.5) * 2
let first = 1 + floor(edge * layout.float(0 ..< 0.3) * path.len)
let last = path.len - 1 - floor(edge * layout.float(0 ..< 0.3) * path.len)
let band = vec[]
for i in first ..< last {
let along = path[i + 1] - path[i - 1]
band.add(path[i] + shift + perp(along / len(along)) * side)
}
let tone = b / bands + layout.float(-0.12 ..< 0.12)
let shades = [colour.at(ramp, along: tone - 0.15), colour.at(ramp, along: tone),
colour.at(ramp, along: tone + 0.1)]
brush.sweep(marks, path: band, width: width / bands * 1.8, ramp: shades,
opacity: 0.85, body: 0.5, taper: 0.2)
}