Annotation of researchv9/jtools/src/Jpic/circgen.c, revision 1.1.1.1

1.1       root        1: #include       <stdio.h>
                      2: #include       "pic.h"
                      3: #include       "y.tab.h"
                      4: 
                      5: struct obj *circgen(type)
                      6: {
                      7:        static int rad[2] = { HT/2, WID/2 };
                      8:        static int rad2[2] = { HT/2, HT/2 };
                      9:        static coord x0, y0, x1, y1, x2, y2;
                     10:        int i, at, t, invis;
                     11:        int with, xwith, ywith;
                     12:        int r, r2;
                     13:        struct obj *p, *ppos;
                     14: 
                     15:        at = invis = 0;
                     16:        with = xwith = ywith = 0;
                     17:        t = (type == CIRCLE) ? 0 : 1;
                     18:        if (type == CIRCLE)
                     19:                r = r2 = getvar("circlerad");
                     20:        else if (type == ELLIPSE) {
                     21:                r = getvar("ellipsewid") / 2;
                     22:                r2 = getvar("ellipseht") / 2;
                     23:        }
                     24:        for (i = 0; i < nattr; i++)
                     25:                switch (attr[i].a_type) {
                     26:                case LJUST: case RJUST: case CENTER: case SPREAD: case FILL: case ABOVE: case BELOW:
                     27:                        savetext(attr[i].a_type, attr[i].a_val);
                     28:                        break;
                     29:                case RADIUS:
                     30:                        r = attr[i].a_val;
                     31:                        break;
                     32:                case DIAMETER:
                     33:                case WIDTH:
                     34:                        r = (attr[i].a_val + 1) / 2;
                     35:                        break;
                     36:                case HEIGHT:
                     37:                        r2 = (attr[i].a_val + 1) / 2;
                     38:                        break;
                     39:                case SAME:
                     40:                        r = rad[t];
                     41:                        r2 = rad2[t];
                     42:                        break;
                     43:                case WITH:
                     44:                        with = attr[i].a_val;
                     45:                        break;
                     46:                case AT:
                     47:                        ppos = (struct obj *) attr[i].a_val;
                     48:                        curx = ppos->o_x;
                     49:                        cury = ppos->o_y;
                     50:                        at++;
                     51:                        break;
                     52:                case INVIS:
                     53:                        invis = INVIS;
                     54:                        break;
                     55:                }
                     56:        if (type == CIRCLE)
                     57:                r2 = r; /* probably superfluous */
                     58:        if (with) {
                     59:                switch (with) {
                     60:                case NORTH:     ywith = -r2; break;
                     61:                case SOUTH:     ywith = r2; break;
                     62:                case EAST:      xwith = -r; break;
                     63:                case WEST:      xwith = r; break;
                     64:                case NE:        xwith = -r * 0.707; ywith = -r2 * 0.707; break;
                     65:                case SE:        xwith = -r * 0.707; ywith = r2 * 0.707; break;
                     66:                case NW:        xwith = r * 0.707; ywith = -r2 * 0.707; break;
                     67:                case SW:        xwith = r * 0.707; ywith = r2 * 0.707; break;
                     68:                }
                     69:                curx += xwith;
                     70:                cury += ywith;
                     71:        }
                     72:        if (!at) {
                     73:                if (isright(hvmode))
                     74:                        curx += r;
                     75:                else if (isleft(hvmode))
                     76:                        curx -= r;
                     77:                else if (isup(hvmode))
                     78:                        cury += r2;
                     79:                else
                     80:                        cury -= r2;
                     81:        }
                     82:        p = makenode(type, 2);
                     83:        p->o_val[0] = rad[t] = r;
                     84:        p->o_val[1] = rad2[t] = r2;
                     85:        if (r <= 0 || r2 <= 0) {
                     86:                yyerror("%s has invalid radius %d\n", (type==CIRCLE) ? "circle" : "ellipse", r<r2 ? r : r2);
                     87:        }
                     88:        p->o_attr = invis;
                     89:        extreme(curx+r, cury+r2);
                     90:        extreme(curx-r, cury-r2);
                     91:        if (type == CIRCLE)
                     92:                dprintf("C %d %d %d\n", curx, cury, r);
                     93:        if (type == ELLIPSE)
                     94:                dprintf("E %d %d %d %d\n", curx, cury, r, r2);
                     95:        if (isright(hvmode))
                     96:                curx += r;
                     97:        else if (isleft(hvmode))
                     98:                curx -= r;
                     99:        else if (isup(hvmode))
                    100:                cury += r2;
                    101:        else
                    102:                cury -= r2;
                    103:        return(p);
                    104: }

unix.superglobalmegacorp.com

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