aboutsummaryrefslogtreecommitdiff
path: root/src/ClientUtils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/ClientUtils.ts')
-rw-r--r--src/ClientUtils.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ClientUtils.ts b/src/ClientUtils.ts
index 972910071..8ecbc55bf 100644
--- a/src/ClientUtils.ts
+++ b/src/ClientUtils.ts
@@ -316,6 +316,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)) {
@@ -327,6 +347,8 @@ export namespace ClientUtils {
return undefined;
}
+
+
export function GetClipboardText(): string {
const textArea = document.createElement('textarea');
document.body.appendChild(textArea);
@@ -703,6 +725,7 @@ export function UpdateIcon(
const newDiv = docViewContent.cloneNode(true) as HTMLDivElement;
newDiv.style.width = width.toString();
newDiv.style.height = height.toString();
+ console.log('width: ' + newDiv.style.width)
replaceCanvases(docViewContent, newDiv);
const htmlString = new XMLSerializer().serializeToString(newDiv);
const nativeWidth = width;