aboutsummaryrefslogtreecommitdiff
path: root/test-nick-colors
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-06-15 04:35:41 +0200
committerPřemysl Eric Janouch <p@janouch.name>2021-06-15 07:09:23 +0200
commitb4dd0052ffc60fbd642729a3e05bcadbd6edd6e1 (patch)
tree68676dbb46fc9d1bb1e214ea9116f6ecaca8754b /test-nick-colors
parente3c47c33fa3a1fb9412198413962ac35f4483240 (diff)
downloadxK-b4dd0052ffc60fbd642729a3e05bcadbd6edd6e1.tar.gz
xK-b4dd0052ffc60fbd642729a3e05bcadbd6edd6e1.tar.xz
xK-b4dd0052ffc60fbd642729a3e05bcadbd6edd6e1.zip
degesch: pick colours based on relative luminance
Replaces the inaccurate Rec. 709 luma we used to use before. This is the first feature here that requires libm, which doesn't seem to be a particularly great sacrifice. Moreover, I've rectified that the input isn't linear in sRGB, and then was even normalized wrong for the luma formula.
Diffstat (limited to 'test-nick-colors')
-rwxr-xr-xtest-nick-colors23
1 files changed, 23 insertions, 0 deletions
diff --git a/test-nick-colors b/test-nick-colors
new file mode 100755
index 0000000..a09f74a
--- /dev/null
+++ b/test-nick-colors
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Check whether the terminal colours filtered by our algorithm are legible
+export example=$(
+ tcc "-run -lm" - <<-EOF
+ #include <stddef.h>
+ #include <stdio.h>
+ #include <math.h>
+
+ $(perl -0777 -ne 'print $& if /^.*?\nfilter_color(?s:.*?)^}$/m' degesch.c)
+
+ void main () {
+ size_t len = 0;
+ int *table = filter_color_cube_for_acceptable_nick_colors (&len);
+ for (size_t i = 0; i < len; i++)
+ printf ("<@\\x1b[38;5;%dmIRCuser\\x1b[m> I'm typing!\n", table[i]);
+ }
+ EOF
+)
+
+# Both should give acceptable results,
+# which results in a bad compromise that the main author himself needs
+xterm -bg black -fg white -e 'echo $example; cat' &
+xterm -bg white -fg black -e 'echo $example; cat' &