diff options
author | Mattias Andrée <maandree@kth.se> | 2019-10-06 14:54:42 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-10-06 14:54:42 +0200 |
commit | f5b396dd73ea28506286e0be09d5e76e802222a2 (patch) | |
tree | cfc285a83639e78858d954cf82815cefe10a55ce /generate-table.c | |
parent | Clean up (diff) | |
download | libred-f5b396dd73ea28506286e0be09d5e76e802222a2.tar.gz libred-f5b396dd73ea28506286e0be09d5e76e802222a2.tar.bz2 libred-f5b396dd73ea28506286e0be09d5e76e802222a2.tar.xz |
Simplify
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | generate-table.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/generate-table.c b/generate-table.c new file mode 100644 index 0000000..ac89af7 --- /dev/null +++ b/generate-table.c @@ -0,0 +1,43 @@ +/* See LICENSE file for copyright and license details. */ +#include "libred.h" +#include <errno.h> +#include <math.h> +#include <string.h> +#include <stdio.h> + +#if __GNUC__ +# pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + +struct xy {double x, y;}; + +static struct xy xy_table[] = { +#include "10deg-xy.i" +}; + +/* define ciexyy_to_srgb() and adjust_luma() */ +#define LIBRED_COMPILING_PARSER +#include "blackbody.c" + +int +main(void) +{ + long int temp = LIBRED_LOWEST_TEMPERATURE; + size_t i, n = sizeof(xy_table) / sizeof(*xy_table); + double r, g, b; + + for (i = 0; i < n; i++, temp += LIBRED_DELTA_TEMPERATURE) { + if (temp == 6500) + r = g = b = 1; + else + ciexyy_to_srgb(xy_table[i].x, xy_table[i].y, 1, &r, &g, &b); + printf("{%a, %a, %a}%s\n", r, g, b, i + 1 == n ? "" : ","); + } + + if (fflush(stdout) || ferror(stdout) || fclose(stdout)) { + perror(NULL); + return -1; + } + + return 0; +} |