ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/aed.c
(Generate patch)

Comparing ray/src/rt/aed.c (file contents):
Revision 1.1 by greg, Thu Feb 2 10:41:16 1989 UTC vs.
Revision 1.2 by greg, Mon Oct 2 17:12:34 1989 UTC

# Line 46 | Line 46 | static char SCCSid[] = "$SunId$ LBL";
46   #define string(s)       fputs(s, stdout)
47   #define flush()         fflush(stdout)
48  
49 < #define  GAMMA          2.0             /* exponent for color correction */
49 > #define  GAMMA          2.2             /* exponent for color correction */
50  
51 < #define  MINCOLOR       8               /* start of device color table */
51 > #define  NCOLORS        244             /* our color table size */
52 > #define  MINPIX         8               /* minimum hardware color */
53  
53 #define  NCOLORS        241             /* our color table size (prime) */
54
55 #define  hashcolr(c)    ((67*(c)[RED]+59*(c)[GRN]+71*(c)[BLU])%NCOLORS)
56
54   #define  NCOLS          512             /* maximum # columns for output */
55   #define  NROWS          512-COMHT       /* maximum # rows for output */
56   #define  COMHT          16              /* height of command line */
# Line 95 | Line 92 | char  *name;
92          byte(BLK); byte(WHT); byte(15);
93          command(SCP);
94          byte('+'); byte(0); byte(1);
95 +        make_cmap(GAMMA);                               /* make color map */
96          errvec = aed_errout;                            /* set error vector */
97          cmdvec = aed_errout;
98          if (wrnvec != NULL)
# Line 125 | Line 123 | aed_clear(x, y)                                        /* clear AED */
123   int  x, y;
124   {
125          command(FFD);
126 <        flush();
127 <        makemap();                              /* init color map */
126 >        maketab();                              /* init color table */
127 >        longwait(1);
128   }
129  
130  
# Line 135 | Line 133 | aed_paintr(col, xmin, ymin, xmax, ymax)                /* paint a re
133   COLOR  col;
134   int  xmin, ymin, xmax, ymax;
135   {
138        int  ndx;
139
140        if ((ndx = colindex(col)) < 0) {                /* full table? */
141                colres >>= 1;
142                redraw();
143                return;
144        }
136          command(SEC);                                   /* draw rectangle */
137 <        byte(ndx+MINCOLOR);
137 >        byte(get_pixel(col)+MINPIX);
138          aedsetcap(xmin, ymin+COMHT);
139          command(DFR);
140          aedcoord(xmax-1, ymax+(-1+COMHT));
# Line 261 | Line 252 | int  *xp, *yp;
252   }
253  
254  
264 static int
265 colindex(col)                   /* return table index for color */
266 COLOR  col;
267 {
268        static COLR  clr;
269        int  hval;
270        register int  ndx, i;
271        
272        mapcolor(clr, col);
273
274        hval = ndx = hashcolr(clr);
275        
276        for (i = 1; i < NCOLORS; i++) {
277                if (colrtbl[ndx][EXP] == 0) {
278                        colrtbl[ndx][RED] = clr[RED];
279                        colrtbl[ndx][GRN] = clr[GRN];
280                        colrtbl[ndx][BLU] = clr[BLU];
281                        colrtbl[ndx][EXP] = COLXS;
282                        newcolr(ndx, clr);
283                        return(ndx);
284                }
285                if (            colrtbl[ndx][RED] == clr[RED] &&
286                                colrtbl[ndx][GRN] == clr[GRN] &&
287                                colrtbl[ndx][BLU] == clr[BLU]   )
288                        return(ndx);
289                ndx = (hval + i*i) % NCOLORS;
290        }
291        return(-1);
292 }
293
294
255   static
256 < newcolr(index, clr)             /* enter a color into our table */
297 < int  index;
298 < COLR  clr;
256 > maketab()                               /* reinitialize the color table */
257   {
258 <        command(SCT);
259 <        byte(index+MINCOLOR);
302 <        byte(1);
303 <        byte(clr[RED]);
304 <        byte(clr[GRN]);
305 <        byte(clr[BLU]);
306 <        flush();
307 < }
308 <
309 <
310 < static
311 < mapcolor(clr, col)                      /* map to our color space */
312 < COLR  clr;
313 < COLOR  col;
314 < {
315 <        register int  i, p;
316 <                                        /* compute color table value */
317 <        for (i = 0; i < 3; i++) {
318 <                p = colval(col,i) * 256.0;
319 <                if (p < 0) p = 0;
320 <                else if (p >= 256) p = 255;
321 <                clr[i] = colrmap[p][i];
322 <        }
323 <        clr[EXP] = COLXS;
324 < }
325 <
326 <
327 < static
328 < makemap()                               /* initialize the color map */
329 < {
330 <        double  pow();
331 <        int  val;
258 >        extern COLR  *get_ctab();
259 >        register COLR  *ctab;
260          register int  i;
261  
262 <        for (i = 0; i < 256; i++) {
263 <                val = pow(i/256.0, 1.0/GAMMA) * colres;
264 <                val = (val*256 + 128) / colres;
265 <                colrmap[i][RED] = colrmap[i][GRN] = colrmap[i][BLU] = val;
266 <                colrmap[i][EXP] = COLXS;
262 >        ctab = get_ctab(NCOLORS);       /* get colors */
263 >        command(SCT);                   /* set color table */
264 >        byte(MINPIX);                   /* starting index */
265 >        byte(NCOLORS&255);              /* number of colors (0==256) */
266 >        for (i = 0; i < NCOLORS; i++) {
267 >                byte(ctab[i][RED]);
268 >                byte(ctab[i][GRN]);
269 >                byte(ctab[i][BLU]);
270          }
340        for (i = 0; i < NCOLORS; i++)
341                colrtbl[i][EXP] = 0;
271   }
272  
273  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines