var colors = ["#FFC30F", "#581845", "#900C3F", "#C70039", "#FF5733", "#1AC7C4"];
createCanvas(windowWidth, windowHeight, WEBGL);
for(let i = 0; i < 3; i++){
in: createVector(random(width), random(height)),
out: createVector(random(width), random(height)),
dirIn: createVector(random(-5, 5), random(-5, 5)),
dirOut: createVector(random(-5, 5), random(-5, 5))
translate(-width/2, -height/2);
for(let i = 0; i < points.length; i++){
if(p.in.x < 0 || p.in.x > width)
if(p.in.y < 0 || p.in.y > height)
if(p.out.x < 0 || p.out.x > width)
if(p.out.y < 0 || p.out.y > height)
dnaConnection(p.in.x, p.in.y,
function dnaConnection(x1, y1, x2, y2) {
const pctParts = 1 / parts;
const t = frameCount / 20;
for (let pct = pctParts; pct <= 1; pct += pctParts) {
const prevLerpX = lerp(x1, x2, pct-pctParts);
const prevLerpY = lerp(y1, y2, pct-pctParts);
const lerpX = lerp(x1, x2, pct);
const lerpY = lerp(y1, y2, pct);
const prevAmp = sin((pct-pctParts) * PI) * 100;
const amp = sin(pct * PI) * 100;
for (let i = 0; i < colors.length; i++) {
const prevZ = cos((pct-pctParts) * PI + t + i) * prevAmp;
const prevY = prevLerpY + sin((pct-pctParts) * PI + t + i) * prevAmp;
const z = cos(pct * PI + t + i) * amp;
const y = lerpY + sin(pct * PI + t + i) * amp;
line(prevLerpX, prevY, prevZ, lerpX, y, z);