def g12_stipple(rng):
"""A 2x2 sub-stipple whose count tracks the field."""
steps = rng.randint(5, 7)
N = rng.choice([30, 40])
c = Canvas(N, _pal(rng), steps, "stipple", "squares")
f = Field(rng, "mesh", warp=rng.uniform(0.2, 0.45), steps=steps)
c.ground_from(f)
C, s = c.C, c.C / 2
for j in range(N):
for i in range(N):
u, v = c.uv(i, j)
n = int(f.raw(u, v) * 5)
k = (f.idx(u, v) + 3) % steps
for m in [0, 3, 1, 2][:n]:
c.sq(i * C + (m % 2) * s, j * C + (m // 2) * s, s, s, k)
return c