dashboard(home): harden matrix-rain fade-trail colour parsing
Follow-up to the matrix-rain backdrop (merged): address argus's review nit on the fadeColor construction. It string-rewrote `rgb(...)`→`rgba(...)`, which silently fills the trail solid if getComputedStyle ever returns a non-`rgb(r, g, b)` form. Extract r,g,b numerically and build the rgba explicitly so the trail always fades regardless of the returned format (same rgb fallback end-to-end). CSS/JS-only, home page.
This commit is contained in:
parent
31001d52e8
commit
1bc26429f2
1 changed files with 8 additions and 2 deletions
|
|
@ -78,8 +78,14 @@ function startMatrixRain() {
|
|||
return /^rgb/.test(c) ? c : fallback;
|
||||
}
|
||||
const glyphColor = resolveColor('--green', 'rgb(166, 227, 161)');
|
||||
const fadeColor = resolveColor('--bg', 'rgb(30, 30, 46)')
|
||||
.replace(/^rgb\(/, 'rgba(').replace(/\)$/, ', 0.09)');
|
||||
// Fade-trail = the bg at low alpha. Pull r,g,b numerically rather than
|
||||
// string-rewriting the rgb() — robust to whatever rgb()/rgba() spacing
|
||||
// getComputedStyle hands back, so the trail always fades (never fills
|
||||
// solid) even if the format shifts.
|
||||
const bgRGB = resolveColor('--bg', 'rgb(30, 30, 46)').match(/(\d+)[^\d]+(\d+)[^\d]+(\d+)/);
|
||||
const fadeColor = bgRGB
|
||||
? `rgba(${bgRGB[1]}, ${bgRGB[2]}, ${bgRGB[3]}, 0.09)`
|
||||
: 'rgba(30, 30, 46, 0.09)';
|
||||
|
||||
const GLYPHS = 'アイウエオカキクケコサシスセソタチツテト0123456789:=*+-<>¦';
|
||||
const CELL = 16; // glyph cell size (px)
|
||||
|
|
|
|||
Loading…
Reference in a new issue