svg`<svg width="${w}" height="${h}">
<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
stroke-width="${strokeWidth}"
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>`