Skip to content

Commit abf3106

Browse files
RuitingMaclaude
andcommitted
Cell: wider cursor reach + momentum-driven alpha boost
- K_DECAY 0.85 → 2.5 cell-widths: pendulum torque from the cursor now carries usefully across ~3 cells instead of dying within 1. - Each cell's |thetaDot| feeds an additive alpha boost on top of the time-faded base — peak MOMENTUM_BOOST = 0.5 at saturation (MOMENTUM_REF = 3 rad/s), squared so quiet cells barely respond and cursor-spiked cells light up sharply. Boost is added (capped at 1) rather than multiplied, so fully decayed cells still light up under the cursor instead of staying invisible. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e375295 commit abf3106

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/components/CellSketch.astro

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@
102102
const TINT_GROUP_SCALE = 4; // cells per noise unit (larger → bigger groups)
103103
const TINT_BIAS = 0.5; // <1 biases toward opaque (rare transparent)
104104
const TINT_LIFETIME_MS = 30000; // time to fade to full transparency
105+
// Momentum-driven alpha boost: cells with high |thetaDot| (typically
106+
// because the cursor's pendulum torque is acting on them) get an
107+
// additional veil on top of the time-faded base. Squared so quiet
108+
// cells barely respond and fast cells light up sharply.
109+
const MOMENTUM_REF = 3.0; // |thetaDot| (rad/s) at saturation
110+
const MOMENTUM_BOOST = 0.5; // peak additive alpha at saturation
105111

106112
// ----- Pre-rendered orbital point sprite (true exp decay) -----
107113
const DOT_HALF = 11;
@@ -356,7 +362,7 @@
356362
const mwx = mouseX + camX - halfW;
357363
const mwy = mouseY + camY - halfH;
358364
const mouseInside = mouseX > -9000;
359-
const K_DECAY = CELL_SIZE * 0.85;
365+
const K_DECAY = CELL_SIZE * 2.5;
360366

361367
const cellCount = (iMax - iMin + 1) * (jMax - jMin + 1);
362368
const flatNeeded = 2 * cellCount;
@@ -481,7 +487,12 @@
481487
const fade = c.birthTime < 0
482488
? 1
483489
: Math.max(0, 1 - (now - c.birthTime) / TINT_LIFETIME_MS);
484-
v.fillAlpha = c.startAlpha * fade;
490+
const baseAlpha = c.startAlpha * fade;
491+
// Quadratic momentum boost — additive on top of base so even
492+
// fully decayed cells light up under the cursor.
493+
const m = Math.min(1, Math.abs(c.thetaDot) / MOMENTUM_REF);
494+
const boost = MOMENTUM_BOOST * m * m;
495+
v.fillAlpha = Math.min(1, baseAlpha + boost);
485496
v.fill = `rgba(${ACCENT[0]},${ACCENT[1]},${ACCENT[2]},${v.fillAlpha})`;
486497

487498
bboxesBuf[k * 4] = Math.max(0, Math.floor(bbMinX));

0 commit comments

Comments
 (0)