svg`<svg width="${w}" height="${h}">
<style>
polyline {
stroke-dasharray: 0 0 0 1000;
animation-duration: 3s;
animation-name: grow;
animation-iteration-count: infinite;
}
@keyframes grow {
0% {
stroke-dasharray: 0 0 0 1000;
}
50% {
stroke-dasharray: 0 0 ${length} 1000;
}
100% {
stroke-dasharray: 0 ${length + 5} ${length} 1000;
}
}
</style>
<rect x="0" y="0" width="${w}" height="${h}" stroke="none" fill="${palette[0]}"></rect>
<g>
${(() => {
const lines = []
return array(nMax).map(d => {
const pos = PVector(Math.random(), Math.random()).mult(PVector(w, h).sub(2 * margin)).add(margin)
const angle = simplex.noise3D(pos.x / noiseScale, pos.y / noiseScale, seed) * Math.PI
const v = PVector.fromAngle(angle).setMag(length/2)
const line = new Line(pos.clone().add(v), pos.clone().sub(v))
if(lines.length < 1 || getIntersections(line, lines).length < 1) {
lines.push(line)
return `<polyline
style="animation-delay: ${Math.random() * 3000 | 0}ms"
stroke-width="${randInt(5, 25)}"
stroke-linecap="${strokeCap}"
stroke="${palette[1 + Math.random() * (palette.length - 1) | 0]}"
points="${line.a.x},${line.a.y} ${line.b.x},${line.b.y}"
/>`
}
}).filter(d => d).join('\n')
})()}
</g>
</svg>`