code review

This commit is contained in:
2026-02-11 12:58:23 -06:00
parent 68e9facdc7
commit d54aa6009a
6 changed files with 78 additions and 80 deletions

View File

@@ -687,7 +687,6 @@ tr {
margin: 2em;
box-shadow: 0 0 0.2rem #fff, 0 0 0.2rem #fff, 0 0 2rem #5271ff,
0 0 0.8rem #5271ff, 0 0 2.8rem #5271ff, inset 0 0 1.3rem #5271ff;
background-image: url('https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.thedermacompany.co.uk%2Fwp-content%2Fuploads%2F2020%2F11%2Fblack-brick-scaled.jpg&f=1&nofb=1&ipt=d10be6df79141da1b4ec0c725575cef0f7b67e957e391662226d66cff02d25e6&ipo=images');
/* background-blend-mode: ; */
text-align: center;
}

View File

@@ -69,23 +69,39 @@ function windowResized() {
function draw() {
background(24);
// Update all balls
for (let i = 0; i < balls.length; i++) {
balls[i].update();
}
// Optimize line drawing with early distance checks
const maxDist = 150;
const maxDistSquared = maxDist * maxDist; // Avoid sqrt in distance calculation
for (let i = 0; i < balls.length - 1; i++) {
const ball1 = balls[i];
for (let j = i + 1; j < balls.length; j++) {
let distance = dist(balls[i].x, balls[i].y, balls[j].x, balls[j].y);
if (distance < 100){
stroke(150);
line(balls[i].x, balls[i].y, balls[j].x, balls[j].y);
}
else if (distance < 150) {
stroke(100);
let chance = 0.3 ** (((random(0.2) + 0.8) * distance) / 150);
if (chance < 0.5) {
stroke(50);
const ball2 = balls[j];
// Quick rejection test using squared distance (faster than sqrt)
const dx = ball2.x - ball1.x;
const dy = ball2.y - ball1.y;
const distSquared = dx * dx + dy * dy;
if (distSquared < maxDistSquared) {
const distance = Math.sqrt(distSquared); // Only calculate sqrt if needed
if (distance < 100) {
stroke(150);
line(ball1.x, ball1.y, ball2.x, ball2.y);
} else {
stroke(100);
const chance = 0.3 ** (((random(0.2) + 0.8) * distance) / 150);
if (chance < 0.5) {
stroke(50);
}
line(ball1.x, ball1.y, ball2.x, ball2.y);
}
line(balls[i].x, balls[i].y, balls[j].x, balls[j].y);
}
}
}

View File

@@ -29,9 +29,14 @@ async function goto(location, { push = true } = {}) {
const content = response[1];
let root = document.getElementById("root");
root.innerHTML = content;
root.querySelectorAll("script").forEach((x) => {
eval(x.innerHTML);
});
root.querySelectorAll("script").forEach((oldScript) => {
const newScript = document.createElement("script");
Array.from(oldScript.attributes).forEach(attr => {
newScript.setAttribute(attr.name, attr.value);
});
newScript.textContent = oldScript.textContent;
oldScript.parentNode.replaceChild(newScript, oldScript);
});
toggleMenu(collapse=true);
document.querySelector("title").textContent = metadata["title"];
if (push) {