function shape(seed, { width = 640, height = 400 } = {}) {
const w = width;
const h = height;
var initSeed = Math.floor(998487523 * seed);
function pseudoRandom() {
var x = Math.sin(initSeed++) * 10000;
return x - Math.floor(x);
}
const spokeCount = Math.floor(pseudoRandom() * 8 + 3);
let d = "";
const r = Math.min(w, h) / 4;
const TAU = Math.PI * 2;
let points = [];
for (let i = 0; i < spokeCount + 1; i++) {
const angle = (i / spokeCount) * TAU;
const x = w / 2 + Math.cos(angle) * r;
const y = h / 2 + Math.sin(angle) * r;
let c = "L";
if (i === 0) {
c = "M";
}
d += `${c} ${x} ${y} `;
points.push({ x, y });
}
const shuffledPoints = points.sort(() => pseudoRandom() - 0.5);
lodash
.chunk(shuffledPoints, 3)
.filter((c) => c.length === 3)
.forEach((chunk) => {
const [a, b, c] = chunk;
d += `C ${a.x} ${a.y} ${b.x} ${b.y} ${c.x} ${c.y} `;
});
for (let i = 0; i < spokeCount; i++) {
const a = shuffledPoints[i];
const b = shuffledPoints[(i + 1) % shuffledPoints.length];
d += `C ${a.x} ${a.y} ${b.x} ${b.y} ${b.x} ${b.y} `;
}
const color = `hsl(${pseudoRandom() * 360}, 100%, 50%)`;
const strokeWidth = Math.floor(pseudoRandom() * 4 + 1) * 2 + 1;
const rotation = pseudoRandom() * 360;
return html`<svg style="width: ${w}px; height: ${h}px; background-color: #212121; overflow: hidden; border-radius: 8px;" viewBox="0 0 ${w} ${h}">
<path d="${d}"
transform="rotate(${rotation}deg ${w / 2} ${h / 2})"
style="filter: drop-shadow(0px 0px ${strokeWidth}px ${color});" fill="none" stroke="${color}" stroke-width="${strokeWidth}" stroke-linecap="round" stroke-linejoin="round" />
/>
</svg>`;
}