fixed some things; even better stars

This commit is contained in:
Ludwig Lehnert 2025-04-15 08:55:57 +02:00
parent 513258cd03
commit a352cbd016
2 changed files with 52 additions and 24 deletions

View File

@ -20,16 +20,4 @@
#252547 100vh #252547 100vh
); );
} }
:global(main) {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 80vh;
color: white;
font-family: "Inter", sans-serif;
text-align: center;
padding: 2rem;
}
</style> </style>

View File

@ -35,16 +35,34 @@
return arr[Math.floor(Math.random() * arr.length)]; return arr[Math.floor(Math.random() * arr.length)];
} }
const distance = (a: [number, number], b: [number, number]) => {
return (
Math.sqrt(Math.pow(a[0] - b[0], 2) + Math.pow(a[1] - b[1], 2)) /
Math.SQRT2
);
};
const connections = stars.map((_, i) => { const connections = stars.map((_, i) => {
let others: number[] = []; let others: number[] = [];
const choosable = [...indices]
.sort((a, b) => {
return (
distance(points[i], points[a]) -
distance(points[i], points[b])
);
})
.slice(0, 15);
const otherCount = Math.max(3, Math.floor(Math.random() * 10)); const otherCount = Math.max(3, Math.floor(Math.random() * 10));
for (let i = 0; i < otherCount; i++) { for (let i = 0; i < otherCount; i++) {
let other = i; let o = i;
while (other === i || others.includes(other)) {
other = chooseRandom(indices); while (o === i || others.includes(o)) {
o = chooseRandom(choosable);
} }
others.push(other);
others.push(o);
} }
return others; return others;
@ -60,11 +78,7 @@
const nidx = chooseRandom(indices); const nidx = chooseRandom(indices);
if (lidx === nidx) continue; if (lidx === nidx) continue;
const [lx, ly] = points[lidx]; const d = distance(points[lidx], points[nidx]);
const [rx, ry] = points[nidx];
const d = Math.sqrt(
Math.pow(lx - rx, 2) + Math.pow(ly - ry, 2),
);
if ((d > 0.4 && Math.random() < 0.8) || d > 0.5) continue; if ((d > 0.4 && Math.random() < 0.8) || d > 0.5) continue;
const line = document.getElementById(`${lidx}-${nidx}`); const line = document.getElementById(`${lidx}-${nidx}`);
@ -76,6 +90,7 @@
4500 + Math.random() * 2500, 4500 + Math.random() * 2500,
); );
console.log(d);
lidx = nidx; lidx = nidx;
return; return;
} }
@ -157,18 +172,25 @@
}); });
</script> </script>
<svelte:head>
<meta
name="keywords"
content="Ludwig Lehnert,Nürnberg,Pegnitz,Nuremberg,Informatik,Computer,Copmuter Science"
/>
</svelte:head>
<svg <svg
id="stars-lines" id="stars-lines"
aria-hidden="true" aria-hidden="true"
style="position: absolute; height: 100vh; width: 100vw; z-index: 0;" style="position: absolute; z-index: 0; height: 100vh; width: 100vw;"
></svg> ></svg>
<div <div
id="stars" id="stars"
style="position: absolute; z-index: 2; height: 100vh; width: 100vw; overflow-x: hidden;" style="position: absolute; z-index: 1; height: 100vh; width: 100vw; overflow-x: hidden;"
></div> ></div>
<main style="position: relative; z-index: 1;"> <main style="position: relative; z-index: 2;">
<h1>Hey, I'm Ludwig 🚀</h1> <h1>Hey, I'm Ludwig 🚀</h1>
<p>Welcome to my digital playground.</p> <p>Welcome to my digital playground.</p>
@ -259,6 +281,8 @@
display: flex; display: flex;
gap: 0.75rem; gap: 0.75rem;
margin-top: 1.5rem; margin-top: 1.5rem;
pointer-events: auto;
} }
.social-links a { .social-links a {
@ -284,6 +308,8 @@
margin-top: 1rem; margin-top: 1rem;
display: flex; display: flex;
gap: 0.5rem; gap: 0.5rem;
pointer-events: auto;
} }
.legal-links a { .legal-links a {
@ -295,4 +321,18 @@
.legal-links a:hover { .legal-links a:hover {
opacity: 0.8; opacity: 0.8;
} }
main {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 80vh;
color: white;
font-family: "Inter", sans-serif;
text-align: center;
padding: 2rem;
pointer-events: none;
}
</style> </style>