Core Algorithm: Generating Interference
This snippet drives the Moiré effect. We draw two identical sets of tightly packed concentric circles, but offset their central anchors slightly. Where the dense lines overlap, optical illusions form.
// Offset anchors slightly to cause interference
let offset = random(5, 30);
let cx1 = width / 2; let cy1 = height / 2 - offset;
let cx2 = width / 2; let cy2 = height / 2 + offset;
let maxRadius = max(width, height) * 0.8;
let densityStep = 6; // Spacing between rings
// First set
for (let r = densityStep; r < maxRadius; r += densityStep) {
circle(cx1, cy1, r * 2);
}
// Second set
for (let r = densityStep; r < maxRadius; r += densityStep) {
circle(cx2, cy2, r * 2);
}