1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/* See LICENSE file for copyright and license details. */
#include "libred.h"
#include <errno.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
#if defined(__GNUC__)
# pragma GCC diagnostic ignored "-Wfloat-equal"
# pragma GCC diagnostic ignored "-Wunsuffixed-float-constants"
#endif
/**
* Colour temperatures in CIE xy (xyY without Y)
*/
static struct xy {double x, y;} 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;
}
|