home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / text / tex / pastex / macros / epic / epic.sty < prev    next >
Text File  |  1991-01-29  |  26KB  |  560 lines

  1. \typeout{%
  2. Enhancements to Picture Environment. Version 1.2 - Released June 1, 1986}
  3. %----------------------------------------------------------------------
  4. % Copyright (C) podar@sbcs (Sunil Podar) July 14,1986.
  5. % You may use this file in whatever way you wish. You are requested to 
  6. % leave this notice intact, and report any bugs, enhancements, comments,
  7. % suggestions, etc. to:
  8. % USmail: Sunil Podar,Dept. of Computer Science,SUNY at Stony Brook,NY 11794.
  9. %  CSNET: podar@sbcs.csnet
  10. %   ARPA: podar%suny-sb.csnet@csnet-relay.arpa
  11. %   UUCP: {allegra, hocsd, philabs, ogcvax}!sbcs!podar
  12. %----------------------------------------------------------------------
  13. % This file contains implementation of:
  14. % \multiputlist    \matrixput    \grid        \picsquare
  15. % \dottedline    \dashline    \drawline    \jput
  16. % \putfile
  17. % Environments: dottedjoin, dashjoin and drawjoin
  18. %
  19. % For documentation, see the accompanying manual.
  20. %----------------------------------------------------------------------
  21. % usage: \multiputlist(x,y)(delta-x,delta-y)[tbrl]{item1,item2,item3,.....}
  22. % \lop and \lopoff taken from TeXbook.
  23. %----------------------------------------------------------------------
  24. \def\lop#1\to#2{\expandafter\lopoff#1\lopoff#1#2}
  25. \long\def\lopoff,#1,#2\lopoff#3#4{\def#4{#1}\def#3{,#2}}
  26. \def\@@mlistempty{,}
  27. \newif\iflistnonempty
  28. \def\multiputlist(#1,#2)(#3,#4){\@ifnextchar
  29. [{\@imultiputlist(#1,#2)(#3,#4)}{\@imultiputlist(#1,#2)(#3,#4)[]}}
  30.  
  31. \long\def\@imultiputlist(#1,#2)(#3,#4)[#5]#6{{%
  32. \@xdim=#1\unitlength \@ydim=#2\unitlength
  33. \listnonemptytrue \def\@@mlist{,#6,} % need this for end condition
  34. \loop
  35. \lop\@@mlist\to\@@firstoflist
  36. \@killglue\raise\@ydim\hbox to\z@{\hskip
  37. \@xdim\@imakepicbox(0,0)[#5]{\@@firstoflist}\hss}
  38. \advance\@xdim #3\unitlength\advance\@ydim #4\unitlength
  39. \ifx\@@mlist\@@mlistempty \listnonemptyfalse\fi
  40. \iflistnonempty
  41. \repeat\relax
  42. \ignorespaces}}
  43. %----------------------------------------------------------------------
  44. % two-dimensional version of \multiput
  45. % \matrixput(0,0)(20,0){5}(0,20){3}{\circle{2}}
  46. %----------------------------------------------------------------------
  47. \newcount\@@multicnt
  48. \def\matrixput(#1,#2)(#3,#4)#5(#6,#7)#8#9{%
  49. \ifnum#5>#8\@matrixput(#1,#2)(#3,#4){#5}(#6,#7){#8}{#9}%
  50. \else\@matrixput(#1,#2)(#6,#7){#8}(#3,#4){#5}{#9}\fi}
  51.  
  52. %% here #5 >= #8
  53. \long\def\@matrixput(#1,#2)(#3,#4)#5(#6,#7)#8#9{{\@killglue%
  54. \@multicnt=#5\relax\@@multicnt=#8\relax%
  55. \@xdim=0pt%
  56. \@ydim=0pt%
  57. \setbox\@tempboxa\hbox{\@whilenum \@multicnt > 0\do {%
  58. %%\typeout{\the\@multicnt, \the\@@multicnt}%
  59. \raise\@ydim\hbox to \z@{\hskip\@xdim #9\hss}%
  60. \advance\@multicnt \m@ne%
  61. \advance\@xdim #3\unitlength\advance\@ydim #4\unitlength}}%
  62. \@xdim=#1\unitlength%
  63. \@ydim=#2\unitlength%
  64. \@whilenum \@@multicnt > 0\do {%
  65. \raise\@ydim\hbox to \z@{\hskip\@xdim \copy\@tempboxa\hss}%
  66. \advance\@@multicnt \m@ne%
  67. \advance\@xdim #6\unitlength\advance\@ydim #7\unitlength}%
  68. \ignorespaces}}
  69. %----------------------------------------------------------------------
  70. %\grid(wd,ht)(delta-wd,delta-ht)[initial-X-integer,initial-Y-integer]
  71. % example: 1. \put(0,0){\grid(95,100)(9.5,10)}
  72. %          2. \put(0,0){\grid(100,100)(10,5)[-10,0]}
  73. %          or \put(0,0){\tiny \grid(100,100)(5,5)[0,0]}%numbers in \tiny font
  74. %----------------------------------------------------------------------
  75. \newcount\d@lta
  76. \newdimen\@delta
  77. \newdimen\@@delta
  78. \newcount\@gridcnt
  79. \def\grid(#1,#2)(#3,#4){\@ifnextchar [{\@igrid(#1,#2)(#3,#4)}%
  80. {\@igrid(#1,#2)(#3,#4)[@,@]}}
  81.  
  82. \long\def\@igrid(#1,#2)(#3,#4)[#5,#6]{%
  83. \makebox(#1,#2){%
  84. \@delta=#1pt\@@delta=#3pt\divide\@delta \@@delta\d@lta=\@delta%
  85. \advance\d@lta \@ne\relax\message{grid=\the\d@lta\space x}%
  86. %% copied the definition of \line(0,1){#2} for some efficiency!.
  87. \multiput(0,0)(#3,0){\d@lta}{\hbox to\z@{\hskip -\@halfwidth \vrule
  88.      \@width \@wholewidth \@height #2\unitlength \@depth \z@\hss}}%
  89. \ifx#5@\relax\else%
  90. \global\@gridcnt=#5%
  91. \multiput(0,0)(#3,0){\d@lta}{%
  92. \makebox(0,-2)[t]{\number\@gridcnt\global\advance\@gridcnt by #3}}%
  93. \global\@gridcnt=#5%
  94. \multiput(0,#2)(#3,0){\d@lta}{\makebox(0,0)[b]{\number\@gridcnt\vspace{2mm}%
  95. \global\advance\@gridcnt by #3}}%
  96. \fi%
  97. \@delta=#2pt\@@delta=#4pt\divide\@delta \@@delta\d@lta=\@delta%
  98. \advance\d@lta \@ne\relax\message{\the\d@lta . }%
  99. %% copied the definition of \line(1,0){#1} for some efficiency!.
  100. \multiput(0,0)(0,#4){\d@lta}{\vrule \@height \@halfwidth \@depth \@halfwidth
  101.      \@width #1\unitlength}%
  102. \ifx#6@\relax\else
  103. \global\@gridcnt=#6%
  104. \multiput(0,0)(0,#4){\d@lta}{%
  105. \makebox(0,0)[r]{\number\@gridcnt\ \global\advance\@gridcnt by #4}}%
  106. \global\@gridcnt=#6%
  107. \multiput(#1,0)(0,#4){\d@lta}{%
  108. \makebox(0,0)[l]{\ \number\@gridcnt\global\advance\@gridcnt by #4}}%
  109. \fi}}
  110. %----------------------------------------------------------------------
  111. % \picsquare is a centered square of dimensions governed by \thinlines,
  112. % \thicklines or \linethickness declarations.
  113. \def\picsquare{\hskip -0.5\@wholewidth%
  114. \vrule height \@halfwidth depth \@halfwidth width \@wholewidth}
  115. %
  116. % just a square dot with reference point at bottom-left
  117. \def\picsquare@bl{\vrule height \@wholewidth depth \z@  width \@wholewidth}
  118. %----------------------------------------------------------------------
  119. % \begin{dottedjoin}{interdot-gap in units}
  120. % .....            
  121. % \end{dottedjoin}
  122. % \begin{dashjoin}{dash-length in units}{interdotgap in each dash}
  123. % .....            
  124. % \end{dashjoin}
  125. % \begin{drawjoin}
  126. % .....
  127. % \end{drawjoin}
  128. % \jput(x,y){character}
  129. % \dottedline[opt. dotcharacter]{dotgap in units}(x1,y1)(x2,y2)...(xN,yN)
  130. % \dashline[#]{dash-length}[opt. dotgap](x1,y1)(x2,y2)...(xN,yN)
  131. % \drawline[#](x1,y1)(x2,y2)...(xN,yN)
  132. %----------------------------------------------------------------------
  133. % definitions for *join environment. had to do all this mess because of
  134. % optional arguments.
  135. %----------------------------------------------------------------------
  136. \newif\if@jointhem \global\@jointhemfalse
  137. \newif\if@firstpoint \global\@firstpointtrue
  138. \newcount\@joinkind
  139. %\newenvironment{dottedjoin}[1]%[opt char]{dotgap}
  140. %{\global\@jointhemtrue \gdef\dotgap@join{#1}\global\@joinkind=0\relax}%
  141. %{\global\@jointhemfalse \global\@firstpointtrue}
  142. %----------------------------------------------------------------------
  143. \def\dottedjoin{\global\@jointhemtrue \global\@joinkind=0\relax
  144.   \bgroup\@ifnextchar[{\@idottedjoin}{\@idottedjoin[\picsquare@bl]}}
  145. \def\@idottedjoin[#1]#2{\gdef\dotchar@join{#1}\gdef\dotgap@join{#2}}
  146. \def\enddottedjoin{\global\@jointhemfalse \global\@firstpointtrue\egroup}
  147. %----------------------------------------------------------------------
  148. \def\dashjoin{\global\@jointhemtrue \global\@joinkind=1\relax
  149.   \bgroup\@ifnextchar[{\@idashjoin}{\@idashjoin[\dashlinestretch]}}
  150. \def\@idashjoin[#1]#2{\edef\dashlinestretch{#1}\gdef\dashlen@join{#2}%
  151. \@ifnextchar[{\@iidashjoin}{\gdef\dotgap@join{}}}
  152. \def\@iidashjoin[#1]{\gdef\dotgap@join{#1}}
  153. \let\enddashjoin\enddottedjoin
  154. %----------------------------------------------------------------------
  155. \def\drawjoin{\global\@jointhemtrue \global\@joinkind=2\relax
  156.   \bgroup\@ifnextchar[{\@idrawjoin}{}}
  157. \def\@idrawjoin[#1]{\def\drawlinestretch{#1}}
  158. \let\enddrawjoin\enddottedjoin
  159. %----------------------------------------------------------------------
  160. %% this is equiv to \put(x,y){#1} when not in {dot*join} environment.
  161. \long\def\jput(#1,#2)#3{{\@killglue\raise#2\unitlength\hbox to \z@{\hskip
  162. #1\unitlength #3\hss}\ignorespaces}
  163. \if@jointhem
  164.  \if@firstpoint \gdef\x@one{#1} \gdef\y@one{#2} \global\@firstpointfalse
  165.  \else\ifcase\@joinkind
  166.     \@dottedline[\dotchar@join]{\dotgap@join\unitlength}%
  167. (\x@one\unitlength,\y@one\unitlength)(#1\unitlength,#2\unitlength)
  168.     \or\@dashline[\dashlinestretch]{\dashlen@join}[\dotgap@join]%
  169. (\x@one,\y@one)(#1,#2)
  170.     \else\@drawline[\drawlinestretch](\x@one,\y@one)(#1,#2)\fi
  171.     \gdef\x@one{#1} \gdef\y@one{#2}
  172.  \fi
  173. \fi}
  174. %----------------------------------------------------------------------
  175. \newdimen\@dotgap
  176. \newdimen\@ddotgap
  177. \newcount\@x@diff
  178. \newcount\@y@diff
  179. \newdimen\x@diff
  180. \newdimen\y@diff
  181. \newbox\@dotbox
  182. \newcount\num@segments
  183. \newcount\num@segmentsi
  184. \newif\ifsqrt@done
  185. %% from sqrtandstuff func basically need \num@segments.
  186. %% given a deltax, deltay and dotgap, it calculates \num@segments = number of
  187. %% segments along the hypotenuse. used by \dottedl