[object Object]

← back to Scarlet Riverboat Masquerade

Harden shade(): clamp t to [0,1] and channels to [0,255] (codex review)

8187692217054671431bbce72f43300d7f5db3b5 · 2026-09-01 16:34:57 -0700 · Steve Abrams

Files touched

Diff

commit 8187692217054671431bbce72f43300d7f5db3b5
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue Sep 1 16:34:57 2026 -0700

    Harden shade(): clamp t to [0,1] and channels to [0,255] (codex review)
---
 index.html | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/index.html b/index.html
index 2d7eae1..ea0d548 100644
--- a/index.html
+++ b/index.html
@@ -288,7 +288,9 @@ function shade(color,t){
   if(String(color).charAt(0)==='#'){ const c=hexToRgb(color); r=c[0];g=c[1];b=c[2]; }
   else if(m && m.length>=3){ r=+m[0]; g=+m[1]; b=+m[2]; }
   else return color;
-  return `rgb(${Math.round(r*(1-t))},${Math.round(g*(1-t))},${Math.round(b*(1-t))})`;
+  const k=1-clamp(t,0,1);
+  const ch=v=>Math.round(clamp(v*k,0,255));
+  return `rgb(${ch(r)},${ch(g)},${ch(b)})`;
 }
 function pal(key,i){ // blended palette between integer chapters
   const m = S.chapterMix; const lo=Math.floor(m), hi=Math.min(2,lo+1), f=m-lo;

← f968af5 Fix NaN-color crash that froze the render loop (pal() rgb st  ·  back to Scarlet Riverboat Masquerade  ·  Add Music Room: stream the Grateful Dead Live Music Archive 85c6c77 →