aboutsummaryrefslogtreecommitdiff
path: root/src/ClientUtils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/ClientUtils.ts')
-rw-r--r--src/ClientUtils.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ClientUtils.ts b/src/ClientUtils.ts
index 630d7edbc..d64210ce2 100644
--- a/src/ClientUtils.ts
+++ b/src/ClientUtils.ts
@@ -322,6 +322,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)) {
@@ -333,6 +353,8 @@ export namespace ClientUtils {
return undefined;
}
+
+
export function GetClipboardText(): string {
const textArea = document.createElement('textarea');
document.body.appendChild(textArea);