marble
A still plate. Rings of ink and of clear water are dropped by turns at a handful of places near a focus. Each drop pushes all the ink already there outward by exactly its own area, so nothing is lost, only moved. Then the water is turned once about an eddy, more the nearer it is.

| Source | Ships as | Gzipped | Target |
|---|---|---|---|
| 47 lines | 1,517 bytes | 965 bytes | svg |
// marble: ink dropped ring by ring on water, each drop pushing out all the ink already there
plate(1920, 2400)
use colour v2
random layout, ink
let deep = [#1b2a4e, #5a1a1f, #12403f, #2a1c16][ink.int(0 ..< 4)]
let water = #f1ebe0
kind drop { at: vec, size: num, tint: color, edge: num }
let drops = drop[]
// where p ends up once every drop from the one given on has pushed it outward
fn carry(p: vec, from: int): vec {
var q = p
for d in drops[from ..< drops.len] {
let away = q - d.at
q = d.at + away * sqrt(1 + pow(d.size / len(away), 2)) // moved out by just the drop's area
}
return q
}
// places near a focus, fed in turn: a ring of ink, a shade paler or darker each time, then clear water
let focus = vec(layout.float(760 ..< 1160), layout.float(950 ..< 1450))
let places = vec[]
for k in 0 ..< layout.int(6 ..< 14) {
places.add(focus + polar(layout.float(0 ..< TAU), layout.float(0 ..< 420)))
}
let width = layout.float(85 ..< 125) / sqrt(places.len) // more places, narrower rings
for round in 0 ..< 26 {
for at in places {
if ink.chance(0.4) { continue }
let tint = colour.mix(deep, toward: water, amount: ink.float(0 ..< 0.35))
drops.add(drop(at, size: width * ink.float(0.5 ..< 1.3), tint: tint, edge: 1.2))
drops.add(drop(at, size: width * ink.float(0.6 ..< 1.8), tint: water, edge: 0))
}
}
// then the water is turned about an eddy near the focus: the nearer a point, the further it turns
let eddy = focus + polar(layout.float(0 ..< TAU), 400), spin = layout.float(-3 ..< 3)
fn stir(p: vec): vec {
let away = p - eddy
return eddy + polar(atan2(away.y, away.x) + spin * exp(-len(away) / 500), len(away))
}
background(water)
for k in 0 ..< drops.len {
let rim = vec[]
for j in 0 ..< 360 {
let start = drops[k].at + polar(TAU * j / 360, drops[k].size)
rim.add(stir(carry(start, from: k + 1)))
}
polygon(rim, fill: drops[k].tint, stroke: colour.darken(deep, amount: 0.3), width: drops[k].edge)
}