summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-04-01 21:15:29 -0400
committerJune McEnroe <june@causal.agency>2018-04-01 21:15:29 -0400
commit72f4cb3c8a55954595144f2ba3a06f1bdc5af654 (patch)
tree5aa2fbd3afd79f05e6a3f5fd2137e4ce7a78342d
parentOutput Linux console escapes from scheme (diff)
downloadsrc-72f4cb3c8a55954595144f2ba3a06f1bdc5af654.tar.gz
src-72f4cb3c8a55954595144f2ba3a06f1bdc5af654.zip
Add HSV output to scheme
Diffstat (limited to '')
-rw-r--r--bin/scheme.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/bin/scheme.c b/bin/scheme.c
index bb700f88..f7c10471 100644
--- a/bin/scheme.c
+++ b/bin/scheme.c
@@ -112,11 +112,9 @@ static void png(const struct Hsv *scheme, uint8_t len) {
     pngInt(crc);
 }
 
-static void linux(const struct Hsv *scheme, uint8_t len) {
-    if (len > 16) len = 16;
+static void hsv(const struct Hsv *scheme, uint8_t len) {
     for (uint8_t i = 0; i < len; ++i) {
-        struct Rgb rgb = toRgb(scheme[i]);
-        printf("\x1B]P%x%02x%02x%02x", i, rgb.r, rgb.g, rgb.b);
+        printf("%g,%g,%g\n", scheme[i].h, scheme[i].s, scheme[i].v);
     }
 }
 
@@ -127,6 +125,14 @@ static void hex(const struct Hsv *scheme, uint8_t len) {
     }
 }
 
+static void linux(const struct Hsv *scheme, uint8_t len) {
+    if (len > 16) len = 16;
+    for (uint8_t i = 0; i < len; ++i) {
+        struct Rgb rgb = toRgb(scheme[i]);
+        printf("\x1B]P%x%02x%02x%02x", i, rgb.r, rgb.g, rgb.b);
+    }
+}
+
 static const struct Hsv R = {   0.0, 1.0, 1.0 };
 static const struct Hsv Y = {  60.0, 1.0, 1.0 };
 static const struct Hsv G = { 120.0, 1.0, 1.0 };
@@ -184,13 +190,14 @@ static struct Terminal genTerminal(struct Ansi ansi) {
 
 int main(int argc, char *argv[]) {
     enum { ANSI, TERMINAL } generate = ANSI;
-    enum { HEX, LINUX, PNG } output = HEX;
+    enum { HSV, HEX, LINUX, PNG } output = HEX;
 
     int opt;
-    while (0 < (opt = getopt(argc, argv, "agltx"))) {
+    while (0 < (opt = getopt(argc, argv, "aghltx"))) {
         switch (opt) {
             case 'a': generate = ANSI; break;
             case 'g': output = PNG; break;
+            case 'h': output = HSV; break;
             case 'l': output = LINUX; break;
             case 't': generate = TERMINAL; break;
             case 'x': output = HEX; break;
@@ -215,6 +222,7 @@ int main(int argc, char *argv[]) {
     }
 
     switch (output) {
+        case HSV: hsv(scheme, len); break;
         case HEX: hex(scheme, len); break;
         case LINUX: linux(scheme, len); break;
         case PNG: png(scheme, len); break;
Parse capabilitiesJune McEnroe The list that I've defined are the ones that I expect to be able to enable probably without any clients breaking... And of course server-time which pounce implements itself. 2019-11-09Avoid the reserved _A names with BIT macroJune McEnroe 2019-11-09Define macro for bit flag enumsJune McEnroe 2019-11-08Check that password is hashedJune McEnroe 2019-11-08Avoid calling getopt_long again after it returns -1June McEnroe On GNU, calling getopt_long again will reset optind back to the first non-option argument, which would cause an infinite loop of reading the same configurtion file forever. 2019-11-08Only change AWAY status for registered clientsJune McEnroe Turns out I did eventually fix this, because I may want to implement "passive clients" for logging or notification stuff, which wouldn't affect AWAY status either. 2019-11-07Just write the example normallyJune McEnroe 2019-11-07Include path in readlinkat errorJune McEnroe 2019-11-07Call clientConsume before clientRecvJune McEnroe This might reduce the frequency of a client getting its own message back because it was behind in the ring when it sent it. 2019-11-06Use -l:filename in Linux.mkJune McEnroe 2019-11-06Fix compat.h for #defined strlcpyJune McEnroe 2019-11-06Allow unsetting LIBRESSL_PREFIXJune McEnroe 2019-11-06Document calico service configurationJune McEnroe 2019-11-06Document SASL EXTERNAL configuration in more detailJune McEnroe 2019-11-06Document pounce service configurationJune McEnroe 2019-11-06Mention Darwin and GNU/Linux in READMEJune McEnroe 2019-11-06Assume LibreSSL from brew on DarwinJune McEnroe 2019-11-06Remove -DNO_EXPLICIT_BZERO from Darwin.mkJune McEnroe 2019-11-06Don't install rc scripts or dirs on LinuxJune McEnroe