import echo::{Context, Cell, contain, prev_cell, cell};
import lygia::generative::snoise::snoise3;
import lygia::generative::random::{random22, random2};
fn map_cell(i: Cell, ctx: Context) -> Cell {
var p = vec2f(i.cp) * vec2(1, 2) * 0.01;
var o = i;
let spread = 0.5; // increase this
let offset = vec2i(-1, i32(round(spread * (random2(vec2f(i.cp) + ctx.time) * 2 - 1))));
let n = prev_cell(offset);
if (i.ch < 32) {
o.fg = n.fg;
o.ch = n.ch;
if (n.ch > 32) {
o.fg = mix(o.fg, o.bg, 0.01);
let animated = 0f; // change to 1f
if (random2(vec2f(i.cp) + animated * ctx.time) > 0.5) {
o.ch = o.ch + 1;
} else {
o.ch = max(o.ch - 1, 34);
}
}
}
return echo::map_cell_selection(o, i, ctx);
}