ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/colorscale.c
Revision: 2.4
Committed: Sat Feb 22 02:07:27 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.3: +1 -4 lines
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

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