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