bnb({
w: 540,
h: 540,
numFrames: 60,
fps: 20,
record: true,
chromaticAberration: .5,
shutterAngle: .6,
samplesPerFrame: 16,
shaderPass: `
precision mediump float;
uniform vec2 u_resolution;
uniform sampler2D u_texture;
void main() {
vec2 uv = gl_FragCoord.xy / u_resolution;
uv.y = 1. - uv.y;
vec3 c = texture2D(u_texture, uv).rgb;
if(uv.x > uv.y) c = vec3(1) - c;
gl_FragColor = vec4(c, 1.);
}
`,
setup: (s, g) => {
g.n = 150;
g.offset = _.range(g.n).map((d) => Math.random());
g.offsetX = _.range(g.n).map((d) => random(-50, 50));
g.offsetY = _.range(g.n).map((d) => random(-50, 50));
},
draw: (s, t, g) => {
s.background(0);
_.range(g.n).map((d, i) => {
const cx =
150 + g.offsetX[i] +
easings.easeQuadInOut(linearstep((t + g.offset[i]) % 1, 0.1, 0.5)) *
240;
const cy =
150 + g.offsetY[i] +
easings.easeQuadInOut(linearstep((t + g.offset[i]) % 1, 0.6, 1.0)) *
240;
const r = 40;
s.circle(cx, cy, r);
s.circle(
s.width + g.offsetX[i] -
(150 +
easings.easeQuadInOut(linearstep((t + g.offset[i]) % 1, 0.1, 0.5)) *
240),
s.height + g.offsetY[i] -
(150 +
easings.easeQuadInOut(linearstep((t + g.offset[i]) % 1, 0.6, 1.0)) *
240),
r
);
});
}
})