diff options
author | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-06-14 16:46:51 -0400 |
---|---|---|
committer | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-06-14 16:46:51 -0400 |
commit | 7d4f2c1777f20c47e0f77bd519469ac16a4366b5 (patch) | |
tree | bd0054d9fdda6dd8c4b5adf23a6272a0d3746b62 /src/ClientUtils.ts | |
parent | 391de70baf2f8744c617cd790b533fea584b9638 (diff) |
background color for highlighted cells done (why did this take 2 hours ~_~)
Diffstat (limited to 'src/ClientUtils.ts')
-rw-r--r-- | src/ClientUtils.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ClientUtils.ts b/src/ClientUtils.ts index d03ae1486..cd2b9b3a9 100644 --- a/src/ClientUtils.ts +++ b/src/ClientUtils.ts @@ -321,6 +321,26 @@ export namespace ClientUtils { return { h: h, s: s, l: l }; } + export function lightenRGB(rVal: number, gVal: number, bVal: number, percent: number): [number, number, number] { + const amount = 1 + percent/100; + const r = rVal * amount; + const g = gVal * amount; + const b = bVal * amount; + + const threshold = 255.999; + const maxVal = Math.max(r, g, b); + if (maxVal <= threshold) { + return [Math.round(r), Math.round(g), Math.round(b)]; + } + const total = r + g + b; + if (total >= 3 * threshold) { + return [Math.round(threshold), Math.round(threshold), Math.round(threshold)]; + } + const x = (3 * threshold - total) / (3 * maxVal - total); + const gray = threshold - x * maxVal; + return [Math.round(gray + x * r), Math.round(gray + x * g), Math.round(gray + x * b)]; + } + export function scrollIntoView(targetY: number, targetHgt: number, scrollTop: number, contextHgt: number, minSpacing: number, scrollHeight: number) { if (!targetHgt) return targetY; // if there's no height, then assume that if (scrollTop + contextHgt < Math.min(scrollHeight, targetY + minSpacing + targetHgt)) { |