1 |
/* RCSid $Id: ccolor.h,v 3.1 2011/02/18 00:40:25 greg Exp $ */ |
2 |
/* |
3 |
* Header file for spectral colors. |
4 |
* |
5 |
*/ |
6 |
|
7 |
#ifndef _MGF_COLOR_H_ |
8 |
#define _MGF_COLOR_H_ |
9 |
#ifdef __cplusplus |
10 |
extern "C" { |
11 |
#endif |
12 |
|
13 |
#define C_CMINWL 380 /* minimum wavelength */ |
14 |
#define C_CMAXWL 780 /* maximum wavelength */ |
15 |
#define C_CNSS 41 /* number of spectral samples */ |
16 |
#define C_CWLI ((C_CMAXWL-C_CMINWL)/(C_CNSS-1)) |
17 |
#define C_CMAXV 10000 /* nominal maximum sample value */ |
18 |
#define C_CLPWM (683./C_CMAXV) /* peak lumens/watt multiplier */ |
19 |
|
20 |
#define C_CSSPEC 01 /* flag if spectrum is set */ |
21 |
#define C_CDSPEC 02 /* flag if defined w/ spectrum */ |
22 |
#define C_CSXY 04 /* flag if xy is set */ |
23 |
#define C_CDXY 010 /* flag if defined w/ xy */ |
24 |
#define C_CSEFF 020 /* flag if efficacy set */ |
25 |
|
26 |
typedef struct { |
27 |
int clock; /* incremented each change */ |
28 |
void *client_data; /* pointer to private client-owned data */ |
29 |
short flags; /* what's been set and how */ |
30 |
short ssamp[C_CNSS]; /* spectral samples, min wl to max */ |
31 |
long ssum; /* straight sum of spectral values */ |
32 |
float cx, cy; /* xy chromaticity value */ |
33 |
float eff; /* efficacy (lumens/watt) */ |
34 |
} C_COLOR; |
35 |
|
36 |
#define C_DEFCOLOR { 1, NULL, C_CDXY|C_CSXY|C_CSSPEC|C_CSEFF,\ |
37 |
{C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,\ |
38 |
C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,\ |
39 |
C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,\ |
40 |
C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,\ |
41 |
C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,\ |
42 |
C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,\ |
43 |
C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV,C_CMAXV},\ |
44 |
(long)C_CNSS*C_CMAXV, 1./3., 1./3., 178.006 } |
45 |
|
46 |
#define c_cval(c,l) ((double)(c)->ssamp[((l)-C_MINWL)/C_CWLI] / (c)->ssum) |
47 |
|
48 |
extern C_COLOR c_dfcolor; /* default color */ |
49 |
|
50 |
extern void c_ccvt(C_COLOR *, int); /* fix color representation */ |
51 |
extern int c_isgrey(C_COLOR *); /* check if color is grey */ |
52 |
/* mix two colors */ |
53 |
extern void c_cmix(C_COLOR *cres, double w1, C_COLOR *c1, |
54 |
double w2, C_COLOR *c2); |
55 |
/* multiply two colors */ |
56 |
extern double c_cmult(C_COLOR *cres, C_COLOR *c1, double y1, |
57 |
C_COLOR *c2, double y2); |
58 |
/* set black body spectrum */ |
59 |
extern int c_bbtemp(C_COLOR *clr, double tk); |
60 |
/* convert to RGB color */ |
61 |
extern void ccy2rgb(C_COLOR *cin, double cieY, float cout[3]); |
62 |
/* convert from RGB color */ |
63 |
extern double rgb2ccy(float cin[3], C_COLOR *cout); |
64 |
|
65 |
#ifdef __cplusplus |
66 |
} |
67 |
#endif |
68 |
#endif /* _MGF_COLOR_H_ */ |