ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/color.h
Revision: 1.1
Committed: Thu Feb 2 10:34:14 1989 UTC (35 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# User Rev Content
1 greg 1.1 /* Copyright (c) 1986 Regents of the University of California */
2    
3     /* SCCSid "$SunId$ LBL" */
4    
5     /*
6     * color.h - header for routines using pixel color values.
7     *
8     * 12/31/85
9     *
10     * Two color representations are used, one for calculation and
11     * another for storage. Calculation is done with three floats
12     * for speed. Stored color values use 4 bytes which contain
13     * three single byte mantissas and a common exponent.
14     */
15    
16     #define RED 0
17     #define GRN 1
18     #define BLU 2
19     #define EXP 3
20     #define COLXS 128 /* excess used for exponent */
21    
22     typedef unsigned char BYTE; /* 8-bit unsigned integer */
23    
24     typedef BYTE COLR[4]; /* red, green, blue, exponent */
25    
26     #define copycolr(c1,c2) (c1[0]=c2[0],c1[1]=c2[1], \
27     c1[2]=c2[2],c1[3]=c2[3])
28    
29     typedef float COLOR[3]; /* red, green, blue */
30    
31     #define colval(col,pri) ((col)[pri])
32    
33     #define setcolor(col,r,g,b) ((col)[RED]=(r),(col)[GRN]=(g),(col)[BLU]=(b))
34    
35     #define copycolor(c1,c2) ((c1)[0]=(c2)[0],(c1)[1]=(c2)[1],(c1)[2]=(c2)[2])
36    
37     #define scalecolor(col,sf) ((col)[0]*=(sf),(col)[1]*=(sf),(col)[2]*=(sf))
38    
39     #define addcolor(c1,c2) ((c1)[0]+=(c2)[0],(c1)[1]+=(c2)[1],(c1)[2]+=(c2)[2])
40    
41     #define multcolor(c1,c2) ((c1)[0]*=(c2)[0],(c1)[1]*=(c2)[1],(c1)[2]*=(c2)[2])
42    
43     #define bright(col) (.30*(col)[RED]+.59*(col)[GRN]+.11*(col)[BLU])
44    
45     #define intens(col) ( (col)[0] > (col)[1] \
46     ? (col)[0] > (col)[2] ? (col)[0] : (col)[2] \
47     : (col)[1] > (col)[2] ? (col)[1] : (col)[2] )
48    
49     #define WHTCOLOR {1.0,1.0,1.0}
50     #define BLKCOLOR {0.0,0.0,0.0}
51     #define WHTCOLR {128,128,128,COLXS+1}
52     #define BLKCOLR {0,0,0,0}