import echo::{Cell, Context, contain, prev_cell_sp};
import lygia::math::rotate2d::rotate2d;
fn map_cell(i: Cell, ctx: Context) -> Cell {
var p = contain(i.sp, ctx.resolution);
var o = i; let I = i;
var acc = vec3f(0f);
for (var i = 0; i < 20; i++) {
let a = f32(i) / 20f * 6.28;
let x = sin(a);
let y = cos(a);
let T: vec2f = rotate2d(0.4 * sin(ctx.time)) * (I.sp + vec2f(x, y) * 0.025) * 0.95;
acc += prev_cell_sp(T).bg;
}
if (o.ch < 33) {
o.bg = acc / 20f * 0.95;
} else {
o.bg = o.fg;
o.fg = vec3(0);
}
return echo::map_cell_selection(o, i, ctx);
}