ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/colorscale.c
Revision: 1.1
Committed: Thu Feb 2 10:49:11 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) 1987 Regents of the University of California */
2    
3     #ifndef lint
4     static char SCCSid[] = "$SunId$ LBL";
5     #endif
6    
7     /*
8     * colorscale.c - program to produce color pallets
9     *
10     * 9/9/87
11     */
12    
13     #include <stdio.h>
14    
15     #include "color.h"
16    
17     int primary = -1;
18     double prival = 0.0;
19    
20    
21     main(argc, argv)
22     int argc;
23     char *argv[];
24     {
25     double atof();
26     int i;
27    
28     for (i = 1; i < argc && argv[i][0] == '-'; i++)
29     switch (argv[i][1]) {
30     case 'r':
31     primary = RED;
32     prival = atof(argv[++i]);
33     break;
34     case 'g':
35     primary = GRN;
36     prival = atof(argv[++i]);
37     break;
38     case 'b':
39     primary = BLU;
40     prival = atof(argv[++i]);
41     break;
42     default:
43     goto userr;
44     }
45     if (primary < 0 || i < argc)
46     goto userr;
47     printargs(argc, argv, stdout);
48     printf("\n");
49     printf("-Y 256 +X 256\n");
50     colorscale();
51     exit(0);
52     userr:
53     fprintf(stderr, "Usage: %s -r|-g|-b value\n", argv[0]);
54     exit(1);
55     }
56    
57    
58     colorscale() /* output our color scale */
59     {
60     COLOR scanline[256];
61     int j;
62     register int i;
63    
64     for (j = 256-1; j >= 0; j--) {
65     for (i = 0; i < 256; i++)
66     switch (primary) {
67     case RED:
68     setcolor(scanline[i],prival,i/256.0,j/256.0);
69     break;
70     case GRN:
71     setcolor(scanline[i],i/256.0,prival,j/256.0);
72     break;
73     case BLU:
74     setcolor(scanline[i],i/256.0,j/256.0,prival);
75     break;
76     }
77     if (fwritescan(scanline, 256, stdout) < 0)
78     goto writerr;
79     }
80     return;
81     writerr:
82     fprintf(stderr, "write error in colorscale\n");
83     exit(1);
84     }
85    
86    
87     printargs(ac, av, fp) /* print arguments to a file */
88     int ac;
89     char **av;
90     FILE *fp;
91     {
92     while (ac-- > 0) {
93     fputs(*av++, fp);
94     putc(' ', fp);
95     }
96     putc('\n', fp);
97     }