Annotation of researchv10no/cmd/ideal/idfilt/tfilt.c, revision 1.1.1.1

1.1       root        1: #include "idfilt.h"
                      2: #undef round
                      3: #define round(x) ((abs(x)<0.00001)?0:(x))
                      4: 
                      5: float xscale, yscale;
                      6: 
                      7: void idjusttext (str)
                      8: char *str;
                      9: {
                     10:        if (
                     11:                strncmp (str, ".IE", 3) &&
                     12:                strncmp (str, "...knot", 7) &&
                     13:                strncmp (str, "...endspline", 12) &&
                     14:                strncmp (str, "...left", 7) &&
                     15:                strncmp (str, "...center", 9) &&
                     16:                strncmp (str, "...right", 8)
                     17:        )
                     18:                fputs (str, stdout);
                     19: }
                     20: 
                     21: void idstart ()
                     22: {
                     23: }
                     24: 
                     25: void idendbound ()
                     26: {
                     27:        float realwidth;
                     28:        if (boundset)
                     29:                return;
                     30:        idminx (-6.0);
                     31:        idmaxy (6.0);
                     32:        idmaxx (6.0);
                     33:        idminy (-6.0);
                     34:        if (!banzai && maxx - minx < 0.2) {
                     35:                maxx += 1;
                     36:                minx -= 1;
                     37:        }
                     38:        if (!banzai && maxy - miny < 0.2) {
                     39:                maxy += 1;
                     40:                miny -= 1;
                     41:        }
                     42:        if (!samescale) {
                     43:                realwidth = width;
                     44:                xscale = width/(maxx - minx);
                     45:                if (!heightset)
                     46:                        yscale = - xscale;
                     47:                else
                     48:                        yscale = height/(miny - maxy);
                     49:        } else
                     50:                realwidth = (maxx - minx)*xscale;
                     51: printf("...%g %g %g\n", width, realwidth, xscale);
                     52:        minx -= 0.5*(colwid - realwidth)/xscale;
                     53:        maxx += 0.5*(colwid - realwidth)/xscale;
                     54:        boundset = TRUE;
                     55:        printf (".ne %4.2fi\n", heightset?height:yscale*(miny - maxy));
                     56: }
                     57: 
                     58: void idline (x1, y1, x2, y2)
                     59: float x1;
                     60: float y1;
                     61: float x2;
                     62: float y2;
                     63: {
                     64:        float X1, Y1, X2, Y2;
                     65:        boolean shortvert, shorthoriz, nonrectilinear;
                     66:        X1 = round(xscale*x1);
                     67:        Y1 = round(yscale*y1);
                     68:        X2 = round(xscale*x2);
                     69:        Y2 = round(yscale*y2);
                     70:        shortvert = X1 == X2 && abs(Y1-Y2) < 0.25;
                     71:        shorthoriz = Y1 == Y2 && abs(X1-X2) < 0.25;
                     72:        nonrectilinear = X1 != X2 && Y1 != Y2;
                     73:        if (wantquality || shortvert || shorthoriz || nonrectilinear)
                     74:                printf ("\\h'%gi'\\v'%gi'\\D'l %gi %gi'\\h'%gi'\\v'%gi'\n.sp -1\n",
                     75:                        round(xscale*(x1-minx)),
                     76:                        round(yscale*(y1-maxy)),
                     77:                        round(xscale*(x2-x1)),
                     78:                        round(yscale*(y2-y1)),
                     79:                        round(-xscale*(x2-minx)),
                     80:                        round(-yscale*(y2-maxy))
                     81:                );
                     82:        else {
                     83:                if (Y1 == Y2)
                     84:                        printf ("\\h'%gi'\\v'%gi'\\l'%gi'\\h'%gi'\\v'%gi'\n.sp -1\n",
                     85:                                round(xscale*(x1-minx)),
                     86:                                round(yscale*(y1-maxy)),
                     87:                                round(xscale*(x2-x1)),
                     88:                                round(-xscale*(x2-minx)),
                     89:                                round(-yscale*(y2-maxy))
                     90:                        );
                     91:                if (X1 == X2)
                     92:                        printf ("\\h'%gi'\\v'%gi'\\L'%gi'\\h'%gi'\\v'%gi'\n.sp -1\n",
                     93:                                round(xscale*(x1-minx)),
                     94:                                round(yscale*(y1-maxy)),
                     95:                                round(yscale*(y2-y1)),
                     96:                                round(-xscale*(x2-minx)),
                     97:                                round(-yscale*(y2-maxy))
                     98:                        );
                     99:        }
                    100: }
                    101: 
                    102: void idcircle (x0, y0, r)
                    103: float x0;
                    104: float y0;
                    105: float r;
                    106: {
                    107:        printf ("\\h'%gi'\\v'%gi'\\D'c %gi'\\h'%gi'\\v'%gi'\n.sp -1\n",
                    108:                round(xscale*(x0-r-minx)),
                    109:                round(yscale*(y0-maxy)),
                    110:                round(2*xscale*r),
                    111:                round(-xscale*(x0+r-minx)),
                    112:                round(-yscale*(y0-maxy))
                    113:        );
                    114: }
                    115: 
                    116: void idarc (x0, y0, x1, y1, x2, y2, t1, t2, r)
                    117: float x0;
                    118: float y0;
                    119: float x1;
                    120: float y1;
                    121: float x2;
                    122: float y2;
                    123: float t1;
                    124: float t2;
                    125: float r;
                    126: {
                    127:        if (xscale*r > 30000.0)
                    128:                idline (x1, y1, x2, y2);
                    129:        else {
                    130:                printf ("\\h'%gi'\\v'%gi'\\D'a %gi %gi %gi %gi'\\h'%gi'\\v'%gi'\n.sp -1\n",
                    131:                        round(xscale*(x1-minx)),
                    132:                        round(yscale*(y1-maxy)),
                    133:                        round(xscale*(x0-x1)),
                    134:                        round(yscale*(y0-y1)),
                    135:                        round(xscale*(x2-x0)),
                    136:                        round(yscale*(y2-y0)),
                    137:                        round(-xscale*(x2-minx)),
                    138:                        round(-yscale*(y2-maxy))
                    139:                );
                    140:        }
                    141: }
                    142: 
                    143: void idleft (x, y, str)
                    144: float x;
                    145: float y;
                    146: char *str;
                    147: {
                    148:        str == ++str;
                    149:        printf ("\\h'%gi'\\v'%gi'%s\\h'-\\w\\(ts%s\\(tsu'\n.sp -1\n",
                    150:                round(xscale*(x-minx)),
                    151:                round(yscale*(y-maxy)),
                    152:                str,
                    153:                str
                    154:        );
                    155: }
                    156: 
                    157: void idcenter (x, y, str)
                    158: float x;
                    159: float y;
                    160: char *str;
                    161: {
                    162:        str = ++str;
                    163:        printf ("\\h'%gi'\\v'%gi'\\h'-\\w\\(ts%s\\(tsu/2u'%s\\h'-\\w\\(ts%s\\(tsu/2u'\n.sp -1\n",
                    164:                round(xscale*(x-minx)),
                    165:                round(yscale*(y-maxy)),
                    166:                str,
                    167:                str,
                    168:                str
                    169:        );
                    170: }
                    171: 
                    172: void idright (x, y, str)
                    173: float x;
                    174: float y;
                    175: char *str;
                    176: {
                    177:        str = ++str;
                    178:        printf ("\\h'%gi'\\v'%gi'\\h'-\\w\\(ts%s\\(tsu'%s\\h'-\\w\\(ts%s\\(tsu'\n.sp -1\n",
                    179:                round(xscale*(x-minx)),
                    180:                round(yscale*(y-maxy)),
                    181:                str,
                    182:                str,
                    183:                str
                    184:        );
                    185: }
                    186: 
                    187: void idendE ()
                    188: {
                    189:        if (boundset)
                    190:                printf (".sp %gi\n.sp 1\n.sp 1\n",
                    191:                        round(yscale*(miny-maxy))
                    192:                );
                    193:        printf (".IE\n");
                    194: }
                    195: 
                    196: void idendF ()
                    197: {
                    198: }
                    199: 
                    200: float osplx, osply;
                    201: 
                    202: void idspline (sx, sy)
                    203: float sx, sy;
                    204: {
                    205:        osplx = sx;
                    206:        osply = sy;
                    207:        printf ("\\h'%gi'\\v'%gi'\\D'~",
                    208:                round(xscale*(osplx-minx)),
                    209:                round(yscale*(osply-maxy))
                    210:        );
                    211: }
                    212: 
                    213: void idknot (sx, sy)
                    214: float sx, sy;
                    215: {
                    216:        printf (" %gi %gi",
                    217:                round(xscale*(sx-osplx)),
                    218:                round(yscale*(sy-osply))
                    219:        );
                    220:        osplx = sx;
                    221:        osply = sy;
                    222: }
                    223: 
                    224: void idendspline ()
                    225: {
                    226:        printf ("'\\h'%gi'\\v'%gi'\n.sp -1\n",
                    227:                round(xscale*(minx-osplx)),
                    228:                round(yscale*(maxy-osply))
                    229:        );
                    230: }
                    231: 
                    232: void idnoerase ()
                    233: {
                    234: }
                    235: 
                    236: 
                    237: void idyeserase ()
                    238: {
                    239: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.