Infinite cells

Fork

Picked

Code

@grid: 1 / 100%;
--colors: #d4572e, #1f5a46, #e6a532, #2f6fb0, #efb3a6;
@content: @pattern(
  z, c, L: t/3, vec3(0), 0;
  repeat(5 as k) {
    n: floor(z) + 4 - k;
    s: z - n;
    g: pos * exp2(-s) + mix(1 / 3, 2 / 3, mod(n, 2));
    id: floor(g);
    u: fract(g) - .5;
    v: rot(u, floor(random(id, 10n + 1) * 4) * PI / 2);
    ty: floor(random(id, 10n + 2) * 10);
    d: match(
      ty < 1, length(u) - .3,
      ty < 2, length(v - vec2(0, -.5)) - .5,
      ty < 3, length(v + .5) - 1,
      ty < 4, (v.x + v.y) * .707,
      ty < 5, (abs(u.x) + abs(u.y) - .38) * .707,
      ty < 6, abs(max(abs(u.x), abs(u.y)) - .25) - .08,
      1
    );
    hue: pick(floor(random(id, 10n + 3) * 5) + 1: $colors);
    cc: mix(#f3ede1, hue, abs(step(.55, random(id, 10n + 4)) - shape(d)));
    R: clamp((s - mix(-3, .3, random(id, 10n))) / .6, 0, 1) * .9 - .1;
    sz: exp2(s);
    w: .04min(sz, 1);
    cc: mix(cc, #1c1a1a, shape((length(u) - R) * sz - w));
    a: 1 - shape(length(u) - R);
    c: mix(c, cc, a);
    L: max(L * (1 - a), shape((.5 - max(abs(u.x), abs(u.y))) * sz - w / 2));
  }
  fill: mix(c, #1c1a1a, L);
);