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

Comparing ray/src/rt/text.c (file contents):
Revision 2.11 by greg, Fri Jun 4 17:03:11 1993 UTC vs.
Revision 2.24 by greg, Thu Feb 12 18:55:50 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  text.c - functions for text patterns and mixtures.
9 *
10 *     11/12/86
6   */
7  
8 + #include "copyright.h"
9 +
10   #include  "ray.h"
11  
12 + #include  "paths.h"
13 +
14   #include  "otypes.h"
15  
16   #include  "font.h"
# Line 45 | Line 44 | static char SCCSid[] = "$SunId$ LBL";
44   *              [spacing]
45   *
46   *  Colortext is identical, except colors are given rather than
47 < *  brightnesses.  Mixtext has foreground and background modifiers:
47 > *  brightnesses.
48   *
49 + *  Mixtext has foreground and background modifiers:
50 + *
51   *      modifier mixtext id
52   *      4+ foremod backmod fontfile text..
53   *      0
# Line 77 | Line 78 | typedef struct {
78          TLINE  tl;                      /* line list */
79   }  TEXT;
80  
80 extern char  *libpath;
81
82 extern char  *fgetword();
83
81   TEXT  *gettext();
82  
83   TLINE  *tlalloc();
84  
85  
86 < text(m, r)
86 > do_text(m, r)
87   register OBJREC  *m;
88   RAY  *r;
89   {
# Line 105 | Line 102 | RAY  *r;
102                  char  *modname = m->oargs.sarg[foreground ? 0 : 1];
103                  if (!strcmp(modname, VOIDID))
104                          omod = OVOID;
105 <                else if ((omod = modifier(modname)) == OVOID) {
105 >                else if ((omod = lastmod(objndx(m), modname)) == OVOID) {
106                          sprintf(errmsg, "undefined modifier \"%s\"", modname);
107                          objerror(m, USER, errmsg);
108                  }
109 <                raytexture(r, omod);
109 >                if (rayshade(r, omod)) {
110 >                        if (m->omod != OVOID)
111 >                                objerror(m, USER, "inappropriate modifier");
112 >                        return(1);
113 >                }
114          } else if (m->otype == PAT_BTEXT) {
115                  if (foreground)
116                          scalecolor(r->pcol, m->oargs.farg[9]);
# Line 127 | Line 128 | RAY  *r;
128                                          m->oargs.farg[14]);
129                  multcolor(r->pcol, cval);
130          }
131 +        return(0);
132   }
133  
134  
# Line 134 | Line 136 | TLINE *
136   tlalloc(s)                      /* allocate and assign text line */
137   char  *s;
138   {
137        extern char  *strcpy();
139          register int  siz;
140          register TLINE  *tl;
141  
# Line 154 | Line 155 | register OBJREC  *tm;
155   {
156   #define  R      (tm->oargs.farg+3)
157   #define  D      (tm->oargs.farg+6)
157        extern char  *strcpy();
158          FVECT  DxR;
159          double  d;
160          FILE  *fp;
# Line 174 | Line 174 | register OBJREC  *tm;
174                                                  /* compute vectors */
175          fcross(DxR, D, R);
176          fcross(t->right, DxR, D);
177 <        d = DOT(D,D)/DOT(t->right,t->right);
177 >        d = DOT(t->right,t->right);
178 >        if (d <= FTINY*FTINY*FTINY*FTINY)
179 >                objerror(tm, USER, "illegal motion vector");
180 >        d = DOT(D,D)/d;
181          for (i = 0; i < 3; i++)
182                  t->right[i] *= d;
183          fcross(t->down, R, DxR);
# Line 195 | Line 198 | register OBJREC  *tm;
198                  tlp = tlp->next;
199          } else {                                /* text file */
200                  if ((s = getpath(tm->oargs.sarg[tndx(tm)],
201 <                                libpath, R_OK)) == NULL) {
201 >                                getrlibpath(), R_OK)) == NULL) {
202                          sprintf(errmsg, "cannot find text file \"%s\"",
203                                          tm->oargs.sarg[tndx(tm)]);
204                          error(USER, errmsg);
# Line 219 | Line 222 | register OBJREC  *tm;
222                                                  /* compute character spacing */
223          i = sndx(tm);
224          d = i < tm->oargs.nfargs ? tm->oargs.farg[i] : 0.0;
225 <        i = d * 256.0;
225 >        i = d * 255.0;
226          t->tl.width = 0;
227          for (tlp = t->tl.next; tlp != NULL; tlp = tlp->next) {
228                  if (i < 0)
# Line 250 | Line 253 | OBJREC  *m;
253                  return;
254          while ((tlp = tp->tl.next) != NULL) {
255                  tp->tl.next = tlp->next;
256 <                free((char *)tlp->spc);
257 <                free((char *)tlp);
256 >                free((void *)tlp->spc);
257 >                free((void *)tlp);
258          }
259 <        free((char *)tp);
259 >        freefont(tp->f);        /* release font reference */
260 >        free((void *)tp);
261          m->os = NULL;
262   }
263  
# Line 275 | Line 279 | OBJREC  *m;
279          x = DOT(v, tp->right);
280          i = sndx(m);
281          if (i < m->oargs.nfargs)
282 <                x *= tp->f->mwidth + 256.*fabs(m->oargs.farg[i]);
282 >                x *= tp->f->mwidth + 255.*fabs(m->oargs.farg[i]);
283          else
284 <                x *= 256.;
284 >                x *= 255.;
285          h = x;
286          i = y = DOT(v, tp->down);
287          if (x < 0.0 || y < 0.0)
288                  return(0);
289          x -= (double)h;
290 <        y = ((i+1) - y)*256.;
290 >        y = ((i+1) - y)*255.;
291                                  /* find the line position */
292          for (tlp = tp->tl.next; tlp != NULL; tlp = tlp->next)
293                  if (--i < 0)
# Line 291 | Line 295 | OBJREC  *m;
295          if (tlp == NULL || h >= tlp->width)
296                  return(0);
297          for (i = 0; (h -= tlp->spc[i]) >= 0; i++)
298 <                if (h < 256 && inglyph(h+x, y,
298 >                if (h < 255 && inglyph(h+x, y,
299                                  tp->f->fg[TLSTR(tlp)[i]&0xff]))
300                          return(1);
301          return(0);
# Line 299 | Line 303 | OBJREC  *m;
303  
304  
305   inglyph(x, y, gl)               /* (x,y) within font glyph gl? */
306 < double  x, y;           /* real coordinates in range [0,256) */
306 > double  x, y;           /* real coordinates in range [0,255) */
307   register GLYPH  *gl;
308   {
309          int  n, ncross;
# Line 323 | Line 327 | register GLYPH  *gl;
327                                          /* positive x axis cross test */
328          while (n--) {
329                  if ((p0[1]<<1 > ylb) ^ (p1[1]<<1 > ylb)) {
330 <                        tv = p0[0]<<1 > xlb | (p1[0]<<1 > xlb) << 1;
330 >                        tv = (p0[0]<<1 > xlb) | ((p1[0]<<1 > xlb) << 1);
331                          if (tv == 03)
332                                  ncross++;
333                          else if (tv)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines