This commit is contained in:
2026-02-06 13:49:04 +01:00
parent 73f47b161c
commit 371c3da66c
2 changed files with 56 additions and 17 deletions

View File

@@ -14,9 +14,9 @@
maxLineWidth: 2.5,
baseOpacity: 0.15,
maxOpacity: 0.6,
magnetRadius: 200,
maxDisplacement: 12,
returnSpeed: 0.25, // Faster return to prevent color lag
magnetRadius: 350, // Larger radius for 16:9/16:10 monitors
maxDisplacement: 15,
returnSpeed: 0.35, // Faster return to reset colors quickly
// Base color (neutral gray)
baseR: 119, baseG: 119, baseB: 100,
// Colors for proximity effect (teal to orange)
@@ -63,7 +63,7 @@
const dy = mouseY - this.originY;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance < CONFIG.magnetRadius && distance > 0) {
if (distance < CONFIG.magnetRadius && distance > 0 && mouseX > -500 && mouseY > -500) {
// Calculate influence (stronger when closer)
const influence = 1 - (distance / CONFIG.magnetRadius);
const easedInfluence = easeOutCubic(influence);
@@ -85,14 +85,20 @@
this.lineWidth = CONFIG.lineWidth + (CONFIG.maxLineWidth - CONFIG.lineWidth) * easedInfluence;
this.colorInfluence = easedInfluence;
} else {
// Return to origin with spring effect
this.currentX += (this.originX - this.currentX) * CONFIG.returnSpeed;
this.currentY += (this.originY - this.currentY) * CONFIG.returnSpeed;
// Return to origin with spring effect - use faster speed for reset
const resetSpeed = CONFIG.returnSpeed * 1.5;
this.currentX += (this.originX - this.currentX) * resetSpeed;
this.currentY += (this.originY - this.currentY) * resetSpeed;
// Fade back to default
this.opacity += (CONFIG.baseOpacity - this.opacity) * CONFIG.returnSpeed;
this.lineWidth += (CONFIG.lineWidth - this.lineWidth) * CONFIG.returnSpeed;
this.colorInfluence += (0 - this.colorInfluence) * CONFIG.returnSpeed;
// Fade back to default - faster color reset
this.opacity += (CONFIG.baseOpacity - this.opacity) * resetSpeed;
this.lineWidth += (CONFIG.lineWidth - this.lineWidth) * resetSpeed;
this.colorInfluence += (0 - this.colorInfluence) * resetSpeed;
// Force reset if very close to default
if (this.colorInfluence < 0.005) this.colorInfluence = 0;
if (Math.abs(this.opacity - CONFIG.baseOpacity) < 0.005) this.opacity = CONFIG.baseOpacity;
if (Math.abs(this.lineWidth - CONFIG.lineWidth) < 0.01) this.lineWidth = CONFIG.lineWidth;
}
}
@@ -239,10 +245,10 @@
const distance = Math.sqrt(dx * dx + dy * dy);
// Check if position OR color needs to return to default
const isReturning = Math.abs(hex.currentX - hex.originX) > 0.1 ||
Math.abs(hex.currentY - hex.originY) > 0.1 ||
hex.colorInfluence > 0.01 ||
hex.opacity > CONFIG.baseOpacity + 0.01;
const isReturning = Math.abs(hex.currentX - hex.originX) > 0.05 ||
Math.abs(hex.currentY - hex.originY) > 0.05 ||
hex.colorInfluence > 0.001 ||
hex.opacity > CONFIG.baseOpacity + 0.001;
if (distance < updateRadius || isReturning) {
hex.update(mouse.x, mouse.y);