def g15_split(rng):
"""Each cell is flat, halved or quartered — two ramp steps per cell."""
steps = rng.randint(5, 8)
N = rng.choice([25, 30, 40])
c = Canvas(N, _pal(rng), steps, "split", "squares")
f = Field(rng, "mesh", warp=rng.uniform(0.2, 0.4), steps=steps)
c.ground_from(f)
C = c.C
for j in range(N):
for i in range(N):
u, v = c.uv(i, j)
k = f.idx(u, v)
lo = min(steps - 1, k + 1)
x, y = i * C, j * C
mode = (i * 7 + j * 3 + k) % 4
if mode == 1:
c.sq(x, y + C / 2, C, C / 2, lo)
elif mode == 2:
c.sq(x + C / 2, y, C / 2, C, lo)
elif mode == 3:
c.sq(x, y, C / 2, C / 2, lo)
c.sq(x + C / 2, y + C / 2, C / 2, C / 2, lo)
return c