1 /* replacement for pltroff.c to produce a TeX file that makes a box */
7 double rangex, rangey; /* probably already available inside pic somewhere */
11 /*-----------copied from old version----------*/
14 arrow(double x0, double y0, double x1, double y1, double w, double h, double ang, int nhead) /* draw arrow (without shaft) */
15 /* head wid w, len h, rotated ang */
16 /* and drawn with nhead lines */
18 double alpha, rot, drot, hyp;
22 rot = atan2(w / 2, h);
23 hyp = sqrt(w/2 * w/2 + h * h);
24 alpha = atan2(y1-y0, x1-x0) + ang;
27 for (i = nhead-1; i >= 0; i--) {
28 drot = 2 * rot / (double) (nhead-1) * (double) i;
29 dx = hyp * cos(alpha + PI - rot + drot);
30 dy = hyp * sin(alpha + PI - rot + drot);
31 line(x1+dx, y1+dy, x1, y1);
36 /*-----------new code----------*/
39 printlf(int line, char *name)
44 fillstart(double v) /* only choose black, light grey (.75), or white, for now */
47 fprintf(TEXFILE, " \\special{bk}%%\n");
49 fprintf(TEXFILE, " \\special{wh}%%\n");
51 fprintf(TEXFILE, " \\special{sh}%%\n");
64 if (strncmp(s, ".ps", 3) == 0) {
65 if (sscanf(&s[3], " %d ", &size) > 0) {
66 fprintf(TEXFILE, " \\special{pn %d}%%\n", size);
68 } else fprintf(stderr, "Malformed .ps command: %s\n", s);
74 space(double x0, double y0, double x1, double y1) /* set limits of page */
76 e0->sidex = e1->sidex = deltx*1000;
77 e0->sidey = e1->sidey = e0->bottom = e1->bottom = delty*1000;
78 range(x0, y0, x1, y1);
84 /* use .005" radius at nominal 9pt pen size */
85 disc(e1->copyx,e1->copyy,(e1->pdiam/9.0)*(4.3/e1->scalex));
89 label(char *s, int t, int nh) /* text s of type t nh half-lines up */
98 fprintf(TEXFILE," \\rlap{\\kern %6.3fin\\lower%6.3fin\\hbox{\\lower%5.2fem\\hbox to 0pt{",
99 INCHES(DTRX(e1->copyx)), INCHES(DTRY(e1->copyy)), nem);
100 fprintf(TEXFILE,t&LJUST?"%s\\hss":(t&RJUST?"\\hss %s":"\\hss %s\\hss"),s);
101 fprintf(TEXFILE,"}}}%%\n");
105 spline(double x, double y, double/*sic*/ n, float *p, int dashed, double ddval)
109 fprintf(TEXFILE," \\special{pa %d %d}%%\n",TRX(x),TRY(y));
110 for(k=0, j=0; k<n; k++, j+=2){
113 fprintf(TEXFILE," \\special{pa %d %d}%%\n",TRX(x),TRY(y));
115 fprintf(TEXFILE," \\special{sp}%%\n");
119 ellipse(double x, double y, double r1, double r2)
121 fprintf(TEXFILE, " \\special{ar %d %d %d %d 0.0 6.2832}%%\n",
122 TRX(x), TRY(y), SCX(r1), -SCY(r2));
126 arc(double xc, double yc, double x0, double y0, double x1, double y1) /* draw arc with center xc,yc */
128 devarc(x0, y0, x1, y1, xc, yc, 1 ); /* radius=1 means counterclockwise */
131 /* If NOEXPANDDASH is defined, use this instead of the normal dotline
132 * in print(). This dotline relies on vec() noticing that e1->pen
133 * is not SOLIDPEN, and putting out a call to a different postscript
139 dotline(double x0, double y0, double x1, double y1, int ddtype, double ddval)
143 e1->pen = (ddtype&DOTBIT)? DOTPEN : DASHPEN;
147 e1->dashlen = e0->dashlen;