mirror of
https://github.com/asimonson1125/asimonson1125.github.io.git
synced 2026-02-24 21:09:49 -06:00
summary
This commit is contained in:
@@ -74,35 +74,40 @@ function draw() {
|
|||||||
balls[i].update();
|
balls[i].update();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optimize line drawing with early distance checks
|
// Draw lines with additive blending so overlaps increase brightness
|
||||||
|
blendMode(ADD);
|
||||||
|
strokeWeight(2);
|
||||||
|
|
||||||
const maxDist = 150;
|
const maxDist = 150;
|
||||||
const maxDistSquared = maxDist * maxDist; // Avoid sqrt in distance calculation
|
const maxDistSquared = maxDist * maxDist;
|
||||||
|
|
||||||
for (let i = 0; i < balls.length - 1; i++) {
|
for (let i = 0; i < balls.length - 1; i++) {
|
||||||
const ball1 = balls[i];
|
const ball1 = balls[i];
|
||||||
for (let j = i + 1; j < balls.length; j++) {
|
for (let j = i + 1; j < balls.length; j++) {
|
||||||
const ball2 = balls[j];
|
const ball2 = balls[j];
|
||||||
|
|
||||||
// Quick rejection test using squared distance (faster than sqrt)
|
|
||||||
const dx = ball2.x - ball1.x;
|
const dx = ball2.x - ball1.x;
|
||||||
const dy = ball2.y - ball1.y;
|
const dy = ball2.y - ball1.y;
|
||||||
const distSquared = dx * dx + dy * dy;
|
const distSquared = dx * dx + dy * dy;
|
||||||
|
|
||||||
if (distSquared < maxDistSquared) {
|
if (distSquared < maxDistSquared) {
|
||||||
const distance = Math.sqrt(distSquared); // Only calculate sqrt if needed
|
const distance = Math.sqrt(distSquared);
|
||||||
|
|
||||||
if (distance < 100) {
|
if (distance < 75) {
|
||||||
stroke(150);
|
stroke(255, 85);
|
||||||
line(ball1.x, ball1.y, ball2.x, ball2.y);
|
line(ball1.x, ball1.y, ball2.x, ball2.y);
|
||||||
} else {
|
} else {
|
||||||
stroke(100);
|
|
||||||
const chance = 0.3 ** (((random(0.2) + 0.8) * distance) / 150);
|
const chance = 0.3 ** (((random(0.2) + 0.8) * distance) / 150);
|
||||||
if (chance < 0.5) {
|
if (chance < 0.5) {
|
||||||
stroke(50);
|
stroke(255, 40);
|
||||||
|
} else {
|
||||||
|
stroke(255, 75);
|
||||||
}
|
}
|
||||||
line(ball1.x, ball1.y, ball2.x, ball2.y);
|
line(ball1.x, ball1.y, ball2.x, ball2.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blendMode(BLEND);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<div class='socials'>
|
<div class='socials'>
|
||||||
<a href='https://github.com/asimonson1125'><img alt='Github' src="{{ url_for('static', filename='icons/github.svg') }}" /></a>
|
<a href='https://github.com/asimonson1125'><img alt='Github' src="{{ url_for('static', filename='icons/github.svg') }}" /></a>
|
||||||
<a href='https://www.instagram.com/an_a.simonson/'><img alt='Instagram' src="{{ url_for('static', filename='icons/instagram.svg') }}" /></a>
|
|
||||||
<a href='https://www.linkedin.com/in/simonsonandrew/'><img alt='LinkedIn' src="{{ url_for('static', filename='icons/linkedin.svg') }}" /></a>
|
<a href='https://www.linkedin.com/in/simonsonandrew/'><img alt='LinkedIn' src="{{ url_for('static', filename='icons/linkedin.svg') }}" /></a>
|
||||||
<a href='mailto:asimonson1125@gmail.com'><img alt='E-mail' src="{{ url_for('static', filename='icons/email.svg') }}" /></a>
|
<a href='mailto:asimonson1125@gmail.com'><img alt='E-mail' src="{{ url_for('static', filename='icons/email.svg') }}" /></a>
|
||||||
<div id='vertLine'></div>
|
<div id='vertLine'></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user