def g03_shells(rng):
"""RADIAL FALLOFF — dot radius set by distance from two off-centre foci,
rippled by a cosine so the falloff breaks into concentric shells. The ripple
rides on a floor, so shells thin out rather than vanishing."""
N = 32
c = Canvas(N, "GEOMETRIC", "dots", "shells", tiles=False)
C = c.C
fx1, fy1 = rng.uniform(.1, .5), rng.uniform(.1, .5)
fx2, fy2 = rng.uniform(.5, .95), rng.uniform(.5, .95)
rip = rng.uniform(4, 10)
bias = rng.uniform(0.6, 1.0)
floor = rng.uniform(0.30, 0.50)
for i in range(N):
for j in range(N):
u, v = (i + 0.5) / N, (j + 0.5) / N
d1 = math.hypot(u - fx1, v - fy1)
d2 = math.hypot(u - fx2, v - fy2)
d = min(d1, d2 * bias)
t = clamp(1.15 - d * 1.15)
t *= floor + (1 - floor) * (0.5 + 0.5 * math.cos(d * rip * math.tau))
r = 0.54 * C * clamp(t) ** 0.6
if r > 0.03 * C:
x, y = c.center(i, j)
c.circle(x, y, r)
return c