Import/export chat styles
This commit is contained in:
parent
6fb76e00c4
commit
8f2061e11d
15 changed files with 663 additions and 47 deletions
26
ts/util/hslToRGB.ts
Normal file
26
ts/util/hslToRGB.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2024 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative
|
||||
export function hslToRGB(
|
||||
h: number,
|
||||
s: number,
|
||||
l: number
|
||||
): {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
} {
|
||||
const a = s * Math.min(l, 1 - l);
|
||||
|
||||
function f(n: number): number {
|
||||
const k = (n + h / 30) % 12;
|
||||
return l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
||||
}
|
||||
|
||||
return {
|
||||
r: Math.round(255 * f(0)),
|
||||
g: Math.round(255 * f(8)),
|
||||
b: Math.round(255 * f(4)),
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue