home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / pc / 0600 / CCE_0657.ZIP / CCE_0657.PD / EEPIC.DOC < prev    next >
Text File  |  1993-10-10  |  15KB  |  434 lines

  1. % eepic Version 1.0 < August 14, 1988 >
  2. %    Written by Conrad Kwok
  3. %
  4. % Internet : kwok@iris.ucdavis.edu
  5. % csnet    : kwok@ucd.csnet
  6. % csnet    : kwok%iris.ucdavis.edu@csnet.relay
  7. % UUCP       : ...!ucbvax!ucdavis!iris!kwok
  8. %
  9. % The macros are in public domain.
  10. % You may distribute or modify it in any ways you like.
  11. % Please report any bugs, enhancements, comments, suggestions, etc.
  12. %
  13. % This style file modify some of the commands in epic[1] and LaTeX[2] such
  14. % that \special commands will be generated in drawing lines if approriate.
  15. % The \special commands generated is the subset of the \specials used
  16. % by tpic[3].
  17. %
  18. % [1] epic is written by Sunil Podar. Please read epic.sty for the
  19. %     copyright notice.
  20. % [2] LaTeX is written by Leslie Lamport. Please read the book LaTeX
  21. % [3] tpic is modified from pic by Tim Morgan
  22. %
  23. %% This file contains extensions of the following epic commands:
  24. %%    \dottedline    \dashline    \drawline
  25. %%    \jput
  26. %%
  27. %% It also contains extensions of the following LaTeX commands:
  28. %%    \circle        \line
  29. %%
  30. %% New commands include:
  31. %%    \Thicklines    \arc        \ellipse
  32. %%    \path        \spline
  33. %%
  34. %% For documentation, please see the accompanying manual
  35. %%
  36. \makeatletter
  37. \typeout{%
  38. Extension to Epic and LaTeX. Version 1.0 - Release August 14, 1988}
  39. %
  40. \newcount\@gphlinewidth
  41. \newcount\@eepictcnt
  42. \newdimen\@tempdimc
  43. \@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736
  44.  
  45. %% Redefine \thinlines, \thicklines
  46. %% See also latex.tex
  47. \def\thinlines{\let\@linefnt\tenln \let\@circlefnt\tencirc
  48. \@wholewidth\fontdimen8\tenln \@halfwidth .5\@wholewidth
  49. \@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736\relax}
  50. \def\thicklines{\let\@linefnt\tenlnw \let\@circlefnt\tencircw
  51. \@wholewidth\fontdimen8\tenlnw \@halfwidth .5\@wholewidth
  52. \@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736
  53. \advance\@gphlinewidth\@ne   % Make the output looks better
  54. \relax}
  55. %%
  56. %% To indicate whether the dot character is defined in the dotted join
  57. %%     environment or not (\@ifnodotdef)
  58. \newif\if@nodotdef \global\@nodotdeftrue
  59. %%
  60. %% Redefine \dottedjoin
  61. \def\dottedjoin{\global\@jointhemtrue \global\@joinkind=0\relax
  62. \bgroup\@ifnextchar[{\global\@nodotdeffalse\@idottedjoin}%
  63. {\global\@nodotdeftrue\@idottedjoin[\@empty]}}
  64. %%----------------------------------------------------------------------
  65. %% Redefine \jput
  66. \long\def\jput(#1,#2)#3{\@killglue\raise#2\unitlength\hbox to \z@{\hskip
  67. #1\unitlength #3\hss}%
  68. \if@jointhem \if@firstpoint \gdef\x@one{#1} \gdef\y@one{#2} \global\@firstpointfalse
  69. \else\ifcase\@joinkind
  70. \if@nodotdef
  71. \@spdottedline{\dotgap@join\unitlength}%
  72. (\x@one\unitlength ,\y@one\unitlength)(#1\unitlength,#2\unitlength)
  73. \else
  74.     \@dottedline[\dotchar@join]{\dotgap@join\unitlength}%
  75. (\x@one\unitlength,\y@one\unitlength)(#1\unitlength,#2\unitlength)
  76. \fi
  77.     \or\@dashline[\dashlinestretch]{\dashlen@join\unitlength}[\dotgap@join]%
  78. (\x@one,\y@one)(#1,#2)
  79.     \else\@drawline[\drawlinestretch](\x@one,\y@one)(#1,#2)\fi
  80. \gdef\x@one{#1}\gdef\y@one{#2}%
  81. \fi
  82. \fi\ignorespaces}
  83. %%
  84. %% Redefine \dottedline to generate special whenever possible.
  85. \def\dottedline{\@ifnextchar [{\@idottedline}{\@ispdottedline}}
  86. %% Similar to \@idottedline but it generate \special
  87. \def\@ispdottedline#1(#2,#3){\@ifnextchar (%
  88. {\@iispdottedline{#1}(#2,#3)}{\relax}}
  89. \def\@iispdottedline#1(#2,#3)(#4,#5){\@spdottedline{#1\unitlength}%
  90. (#2\unitlength,#3\unitlength)(#4\unitlength,#5\unitlength)%
  91. \@ispdottedline{#1}(#4,#5)}
  92. %
  93. \def\@spdottedline#1(#2,#3)(#4,#5){%
  94. \@tempcnta \@gphlinewidth\relax
  95. \advance\@tempcnta by 2     % solely for better output
  96. \special{pn \the\@tempcnta}%
  97. \@tempdimc=#2\relax
  98. \@tempcnta \@tempdimc\relax \advance\@tempcnta 2368 \divide\@tempcnta 4736
  99. \@tempdimc=#3\relax
  100. \@tempcntb -\@tempdimc\relax\advance\@tempcntb -2368 \divide\@tempcntb 4736
  101. \@paspecial{\the\@tempcnta}{\the\@tempcntb}%
  102. \@tempdimc=#4\relax
  103. \@tempcnta \@tempdimc\relax \advance\@tempcnta 2368 \divide\@tempcnta 4736
  104. \@tempdimc=#5\relax
  105. \@tempcntb -\@tempdimc\relax\advance\@tempcntb -2368 \divide\@tempcntb 4736
  106. \@paspecial{\the\@tempcnta}{\the\@tempcntb}%
  107. \@tempdimc=#1\relax
  108. %%
  109. %% Generate the pen width in terms of inch with 3 decimal digit.
  110. \@tempcnta \@tempdimc\relax \advance\@tempcnta 2368 \divide\@tempcnta 4736
  111. %% \@tempcnta contain the pen width in terms of thousandth of a inch
  112. %% Then it is converted back to inch. I know the way I use is dumb but
  113. %% I cannot think of any better method
  114. \@tempcntb \@tempcnta\relax \divide\@tempcntb 1000
  115. \multiply \@tempcntb 1000 \advance\@tempcnta -\@tempcntb
  116. \divide\@tempcntb 1000
  117. \ifnum\@tempcnta < 10
  118. \special{dt \the\@tempcntb.00\the\@tempcnta}%
  119. \else\ifnum\@tempcnta < 100
  120. \special{dt \the\@tempcntb.0\the\@tempcnta}%
  121. \else
  122. \special{dt \the\@tempcntb.\the\@tempcnta}%
  123. \fi\fi
  124. \ignorespaces
  125. }
  126. %
  127. \def\@iiidashline[#1]#2[#3](#4,#5)(#6,#7){%
  128. \@dashline[#1]{#2\unitlength}[#3](#4,#5)(#6,#7)%
  129. \@iidashline[#1]{#2}[#3](#6,#7)}
  130. %
  131. %% Redefine \@dashline
  132. \long\def\@dashline[#1]#2[#3](#4,#5)(#6,#7){{%
  133. \x@diff=#6\unitlength \advance\x@diff by -#4\unitlength
  134. \y@diff=#7\unitlength \advance\y@diff by -#5\unitlength
  135. %% correction to get actual width since the dash-length as taken in arguement
  136. %% is the center-to-center of the end-points.
  137. \@tempdima=#2\relax \advance\@tempdima -\@wholewidth
  138. \sqrtandstuff{\x@diff}{\y@diff}{\@tempdima}%
  139. \ifnum\num@segments <3 \num@segments=3\fi% min number of dashes I can plot
  140. % is 2, 1 at either end, thus min num@segments is 3 (including 'empty dash').
  141. \@tempdima=\x@diff \@tempdimb=\y@diff
  142. \divide\@tempdimb by\num@segments
  143. \divide\@tempdima by\num@segments
  144. %% ugly if-then-else. If optional dotgap specified, then use it otherwise
  145. %% make a solid dash.
  146. {\ifx#3\@empty \relax
  147. \ifdim\@tempdima < 0pt \x@diff=-\@tempdima\else\x@diff=\@tempdima\fi
  148. \ifdim\@tempdimb < 0pt \y@diff=-\@tempdimb\else\y@diff=\@tempdimb\fi
  149. \global\setbox\@dotbox\hbox{%
  150. \@absspdrawline(0pt,0pt)(\@tempdima,\@tempdimb)}%
  151. \else\global\setbox\@dotbox\hbox{%
  152. \@spdottedline{#3\unitlength}(0pt,0pt)(\@tempdima,\@tempdimb)}%
  153. \fi}%
  154. \advance\x@diff by -\@tempdima % both have same sign
  155. \advance\y@diff by -\@tempdimb
  156. %
  157. %%here we correct the number of dashes to be put by reducing them
  158. %%appropriately. (num@segments*\@wholewidth) is in some way the slack we
  159. %%have,and division by dash-length gives the reduction. reduction =
  160. %%(2*num@segments*\@wholewidth)/dash-length
  161. %% (num@segments includes empty ones)
  162. \@tempdima=\num@segments\@wholewidth \@tempdima=2\@tempdima
  163. \@tempcnta\@tempdima\relax \@tempdima=#2\relax \@tempdimb=0.5\@tempdima
  164. \@tempcntb\@tempdimb\relax \advance\@tempcnta by \@tempcntb % round-off error
  165. \divide\@tempcnta by\@tempdima \advance\num@segments by -\@tempcnta
  166. %
  167. \ifnum #1=0 \relax\else\ifnum #1 < -100
  168. \typeout{***dashline: reduction > -100 percent implies blankness!***}
  169. \else\num@segmentsi=#1 \advance\num@segmentsi by 100
  170. \multiply\num@segments by\num@segmentsi \divide\num@segments by 100
  171. \fi\fi
  172. %
  173. \divide\num@segments by 2 % earlier num@segments included 'empty dashes' too.
  174. \ifnum\num@segments >0 % if =0 then don't divide => \x@diff & \y@diff
  175. \divide\x@diff by\num@segments%   remain same.
  176. \divide\y@diff by\num@segments
  177. \advance\num@segments by\@ne %for the last segment for which I subtracted
  178.                   %\@tempdima & \@tempdimb from \x@diff & \y@diff
  179. \else\num@segments=2 % one at each end.
  180. \fi
  181. %%\typeout{num@segments finally = \the\num@segments}
  182. %% equiv to \multiput(#4,#5)(\x@diff,\y@diff){\num@segments}{\copy\@dotbox}
  183. %% with arguements in absolute dimensions.
  184. \@xdim=#4\unitlength \@ydim=#5\unitlength
  185. \@killglue
  186. \loop \ifnum\num@segments > 0
  187. \unskip\raise\@ydim\hbox to\z@{\hskip\@xdim \copy\@dotbox\hss}%
  188. \advance\num@segments \m@ne\advance\@xdim\x@diff\advance\@ydim\y@diff%
  189. \repeat}%
  190. \ignorespaces}
  191. %% redefine \@drawline
  192. %
  193. \def\@drawline[#1](#2,#3)(#4,#5){{%
  194. \@drawitfalse\@horvlinefalse
  195. \ifnum#1 <0 \relax\else\@horvlinetrue\fi
  196. \if@horvline
  197. \@spdrawline(#2,#3)(#4,#5)
  198. \else\@drawittrue\fi
  199. %%-------------------------------
  200. \if@drawit
  201. \ifnum #1=0 \relax \else\ifnum #1 < -99
  202. \typeout{***drawline: reduction <= -100 percent implies blankness!***}%
  203. \else\num@segmentsi=#1 \advance\num@segmentsi by 50
  204. \multiply\num@segmentsi 2
  205. \fi\fi
  206. \@dashline[\num@segmentsi]{10pt}[\@empty](#2,#3)(#4,#5)
  207. \fi}\ignorespaces}% for \if@drawit
  208. %
  209. \def\@spdrawline(#1,#2)(#3,#4){%
  210. \@absspdrawline(#1\unitlength,#2\unitlength)(#3\unitlength,#4\unitlength)
  211. \ignorespaces
  212. }
  213. \def\@absspdrawline(#1,#2)(#3,#4){%
  214. \special{pn \the\@gphlinewidth}%
  215. \@tempdimc=#1\relax
  216. \@tempcnta \@tempdimc\relax \advance\@tempcnta 2368 \divide\@tempcnta 4736
  217. \@tempdimc=#2\relax
  218. \@tempcntb -\@tempdimc\relax \advance\@tempcntb -2368 \divide\@tempcntb 4736
  219. \@paspecial{\the\@tempcnta}{\the\@tempcntb}%
  220. \@tempdimc=#3\relax
  221. \@tempcnta\@tempdimc\relax \advance\@tempcnta 2368 \divide\@tempcnta 4736
  222. \@tempdimc=#4\relax
  223. \@tempcntb -\@tempdimc\relax \advance\@tempcntb -2368 \divide\@tempcntb 4736
  224. \@paspecial{\the\@tempcnta}{\the\@tempcntb}%
  225. \special{fp}%
  226. \ignorespaces
  227. }
  228. %%----------------------------------------------------------------------
  229. \def\@paspecial#1#2{%
  230. \special{pa #1 #2}%
  231. }
  232. %%
  233. %% Functions below modify the LaTeX commands and some additional commands
  234. %% are not supported by LaTeX nor epic such as ThickLines and arc.
  235. %%
  236. %% The macros are for use with LaTeX picture environment
  237. %% By including the macro file, you can draw
  238. %%   1) \line in any slope
  239. %%   2) \circle with any radius
  240. %%   3) \ellipse with any x-axis and y-axis length
  241. %%   4) Circular \arc by giving starting and ending angle (in radius)
  242. %%
  243. %% Furthermore you may draw lines in any thickness.
  244. %%
  245. %%
  246. %% Redefine \thinlines, \thicklines and define \Thickline
  247. %% See also latex.tex
  248. \def\Thicklines{\let\@linefnt\tenlnw \let\@circlefnt\tencircw
  249. \@wholewidth\fontdimen8\tenlnw \@wholewidth 1.5\@wholewidth
  250. \@halfwidth .5\@wholewidth
  251. \@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736\relax}
  252. %%
  253. %% Generate the \special command for drawing arc
  254. \def\@circlespecial#1#2#3#4{%
  255.           \special{pn \the\@gphlinewidth}%
  256.           \special{ar 0 0 #1 #2 #3 #4}
  257. }
  258. %%
  259. %% Command for drawing an arc. Elliptical arc command can be generated
  260. %% but all iptex program I saw so far does not support that.
  261. \def\@arc#1#2#3#4{%
  262. %% convert TeX dimension to length in terms thousandth of an inch
  263.     \@tempdima #1\unitlength
  264.     \@tempdimb #2\unitlength
  265. \@tempcnta\@tempdima \advance\@tempcnta 4736 \divide\@tempcnta 9473
  266.     \@tempcntb\@tempdimb \advance\@tempcntb 4736 \divide\@tempcntb 9473
  267.     \setbox\@tempboxa\hbox{%
  268.         \@circlespecial{\the\@tempcnta}{\the\@tempcntb}{#3}{#4}}%
  269. \wd\@tempboxa\z@ \box\@tempboxa}
  270. %%
  271. %% Command for drawing Circle and Ellipse in terms of \@arc
  272. %% replace original \circle
  273. \def\circle{%
  274. \@ifstar{\special{bk}\@circle}{\@circle}}
  275. \def\@circle#1{\@arc{#1}{#1}{0}{6.2832}}
  276. \def\ellipse{%
  277. \@ifstar{\special{bk}\@ellipse}{\@ellipse}}
  278. \def\@ellipse#1#2{{\@arc{#1}{#2}{0}{6.2832}}}
  279. \def\arc#1#2#3{\@arc{#1}{#1}{#2}{#3}}
  280. %%
  281. %% Generate \special commands for drawing line
  282. \def\@linespecial#1#2{%
  283.           \special{pn \the\@gphlinewidth}%
  284.           \special{pa 0 0}%
  285.           \special{pa #1 #2}%
  286.           \special{fp}%
  287. }
  288. %%
  289. %% Replace original \@sline
  290. %% For description, see latex.tex
  291. \def\@sline{%
  292.     \ifnum\@xarg< 0
  293.       \@negargtrue \@xarg -\@xarg \@tempdima -\@linelen
  294.     \else
  295.       \@negargfalse \@tempdima\@linelen
  296.     \fi
  297. %% truncation is used in arithmetic
  298.     \@tempcnta\@linelen \divide\@tempcnta 4736
  299. \@yyarg -\@yarg \multiply\@yyarg \@tempcnta \divide\@yyarg\@xarg
  300.     \if@negarg
  301.         \@tempcnta -\@tempcnta
  302.     \fi
  303.     \setbox\@linechar\hbox{\@linespecial{\the\@tempcnta}{\the\@yyarg}}%
  304.     \wd\@linechar\@tempdima
  305.     \@clnht\@linelen
  306. \multiply\@clnht\@yarg
  307. \divide\@clnht\@xarg
  308.     \ifnum\@yarg< 0
  309.       \@clnht -\@clnht
  310.       \ht\@linechar\z@ \dp\@linechar\@clnht
  311.     \else
  312.       \ht\@linechar\@clnht \dp\@linechar\z@
  313.     \fi
  314.     \box\@linechar
  315. %% Codes below (till end of the command) is only necessary
  316. %% when used with \@svector
  317.     \if@negarg
  318.       \@yyarg -\@yarg
  319.     \else
  320.       \@yyarg \@yarg
  321.     \fi
  322.     \setbox\@linechar\hbox{\@linefnt\@getlinechar(\@xarg,\@yyarg)}%
  323.     \ifnum\@yarg> 0
  324.       \let\@upordown\raise
  325.       \advance\@clnht -\ht\@linechar
  326.     \else
  327.       \let\@upordown\lower
  328.     \fi
  329.     \if@negarg \kern\wd\@linechar \fi
  330. }
  331. %%
  332. \def\spline(#1,#2){%
  333. \special{pn \the\@gphlinewidth}%
  334. \@spline(#1,#2)%
  335. }
  336. \def\@spline(#1,#2){%
  337. \@tempdima #1\unitlength
  338. \@tempdimb #2\unitlength
  339. \@tempcnta \@tempdima \advance\@tempcnta 2368 \divide\@tempcnta 4736
  340. \@tempcntb -\@tempdimb \advance\@tempcntb -2368 \divide\@tempcntb 4736
  341. \@paspecial{\the\@tempcnta}{\the\@tempcntb}%
  342. \@ifnextchar ({\@spline}{\special{sp}}%
  343. }
  344. \def\path(#1,#2){%
  345. \special{pn \the\@gphlinewidth}%
  346. \@path(#1,#2)%
  347. }
  348. \def\@path(#1,#2){%
  349. \@tempdima #1\unitlength
  350. \@tempdimb #2\unitlength
  351. \@tempcnta \@tempdima \advance\@tempcnta 2368 \divide\@tempcnta 4736
  352. \@tempcntb -\@tempdimb \advance\@tempcntb -2368 \divide\@tempcntb 4736
  353. \@paspecial{\the\@tempcnta}{\the\@tempcntb}%
  354. \@ifnextchar ({\@path}{\special{fp}}%
  355. }
  356.  
  357. %%%%%%%%%% Beginning of \oval %%%%%%%%%%%%%%%
  358. \newdimen\maxovaldiam \maxovaldiam 40pt\relax
  359.  
  360. \def\@oval(#1,#2)[#3]{\begingroup\boxmaxdepth \maxdimen
  361. \@ovttrue \@ovbtrue \@ovltrue \@ovrtrue
  362. \@tfor\@tempa :=#3\do{\csname @ov\@tempa false\endcsname}\@ovxx
  363. #1\unitlength \@ovyy #2\unitlength
  364. \@tempdimb \ifdim \@ovyy >\@ovxx \@ovxx\else \@ovyy \fi
  365. \@ovro \ifdim \@tempdimb>\maxovaldiam \maxovaldiam\else\@tempdimb\fi\relax
  366. \divide \@ovro \tw@
  367. \@ovdx\@ovxx \divide\@ovdx \tw@
  368. \@ovdy\@ovyy \divide\@ovdy \tw@
  369. \setbox\@tempboxa \hbox{%
  370. \if@ovr \@ovverta\fi
  371. \if@ovl \kern \@ovxx \@ovvertb\kern -\@ovxx \fi
  372. \if@ovt \@ovhorz \kern -\@ovxx \fi
  373. \if@ovb \raise \@ovyy \@ovhorz \fi}
  374. \ht\@tempboxa\z@ \dp\@tempboxa\z@
  375. \@put{-\@ovdx}{-\@ovdy}{\box\@tempboxa}%
  376. \endgroup}
  377.  
  378. \def\@qcirc#1#2#3#4{%
  379. \special{pn \the\@gphlinewidth}%
  380. \@eepictcnt \@gphlinewidth \divide\@eepictcnt 2
  381. \@tempcnta #1
  382. \advance\@tempcnta 2368 \divide\@tempcnta 4736
  383. \advance\@tempcnta\@eepictcnt
  384. \@tempcntb #2 \divide\@tempcntb 4736 \advance\@tempcntb 2
  385. \hbox{%
  386. \@qcircspecial{\the\@tempcnta}{-\the\@eepictcnt}{\the\@tempcntb}{#3}{#4}}%
  387. }
  388. \def\@qcircspecial#1#2#3#4#5{\special{ar #1 #2 #3 #3 #4 #5}}
  389.  
  390. \def\@ovverta{\vbox to \@ovyy{%
  391. \if@ovb
  392. \kern \@ovro
  393. \@qcirc{\@ovro}{\@ovro}{3.1416}{4.7124}\nointerlineskip
  394. \else
  395. \kern \@ovdy
  396. \fi
  397. \leaders\vrule width \@wholewidth\vfil \nointerlineskip
  398. \if@ovt
  399. \@qcirc{\@ovro}{\@ovro}{1.5708}{3.1416}\nointerlineskip
  400. \kern \@ovro
  401. \else
  402. \kern \@ovdy
  403. \fi
  404. }\kern -\@wholewidth}
  405.  
  406. \def\@ovvertb{\vbox to \@ovyy{%
  407. \if@ovb
  408. \kern \@ovro
  409. \@qcirc{-\@ovro}{\@ovro}{4.6124}{6.2832}\nointerlineskip
  410. \else
  411. \kern \@ovdy
  412. \fi
  413. \leaders\vrule width \@wholewidth\vfil \nointerlineskip
  414. \if@ovt
  415. \@qcirc{-\@ovro}{\@ovro}{0}{1.6708}\nointerlineskip
  416. \kern \@ovro
  417. \else
  418. \kern \@ovdy
  419. \fi
  420. }\kern -\@wholewidth}
  421.  
  422. \def\@ovhorz{\hbox to \@ovxx{%
  423. \if@ovr \kern \@ovro\else \kern \@ovdx \fi
  424. \leaders \hrule height \@wholewidth \hfil
  425. \if@ovl \kern \@ovro\else \kern \@ovdx \fi
  426. }}
  427. %%%%%%%%% End of \oval %%%%%%%%%%%%%%
  428.  
  429. \def\allinethickness#1{\let\@linefnt\tenlnw \let\@circlefnt\tencircw
  430. \@wholewidth #1 \@halfwidth .5\@wholewidth
  431. \@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736\relax}
  432. \makeatother
  433.  
  434.