Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

ts: Convert colorspace to typescript.

Priyank Patel3b46ec0e5fe6
diff --git a/static/js/colorspace.js b/static/js/colorspace.ts
similarity index 79%
rename from static/js/colorspace.js
rename to static/js/colorspace.ts
index 38633a8d94d..0ee968e373b 100644
--- a/static/js/colorspace.js
+++ b/static/js/colorspace.ts
@@ -2,7 +2,7 @@
// value in [0, 1].
//
// https://en.wikipedia.org/wiki/SRGB#The_reverse_transformation
-export function sRGB_to_linear(v) {
+export function sRGB_to_linear(v: number): number {
v = v / 255;
if (v <= 0.04045) {
return v / 12.92;
@@ -12,7 +12,7 @@ export function sRGB_to_linear(v) {
// Compute luminance (CIE Y stimulus) from linear intensity
// of sRGB / Rec. 709 primaries.
-export function rgb_luminance(channel) {
+export function rgb_luminance(channel: [number, number, number]): number {
return 0.2126 * channel[0] + 0.7152 * channel[1] + 0.0722 * channel[2];
}
@@ -20,7 +20,7 @@ export function rgb_luminance(channel) {
// to lightness (perceptual, CIE L*)
//
// https://en.wikipedia.org/wiki/Lab_color_space#Forward_transformation
-export function luminance_to_lightness(luminance) {
+export function luminance_to_lightness(luminance: number): number {
let v;
if (luminance <= 216 / 24389) {
v = (841 / 108) * luminance + 4 / 29;