aboutsummaryrefslogtreecommitdiff
path: root/src/ClientUtils.ts
diff options
context:
space:
mode:
authorNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-06-14 16:46:51 -0400
committerNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-06-14 16:46:51 -0400
commit7d4f2c1777f20c47e0f77bd519469ac16a4366b5 (patch)
treebd0054d9fdda6dd8c4b5adf23a6272a0d3746b62 /src/ClientUtils.ts
parent391de70baf2f8744c617cd790b533fea584b9638 (diff)
background color for highlighted cells done (why did this take 2 hours ~_~)
Diffstat (limited to 'src/ClientUtils.ts')
-rw-r--r--src/ClientUtils.ts20
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)) {