home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / useful / dist / text / tex / pastex / macros / eepic / eepic.sty next >
Text File  |  1991-01-29  |  17KB  |  470 lines

  1. % eepic Version 1.1b < Febrary 7, 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        \oval
  29. %%
  30. %% New commands include:
  31. %%    \Thicklines    \arc        \ellipse
  32. %%    \path        \spline        \allinethickness
  33. %%
  34. %% New commands for eepic 1.1
  35. %%    \blacken    \whiten        \shade
  36. %%    \texture    \filltype{type} type=black|white|shade
  37. %%
  38. %% For documentation, please see the accompanying manual
  39. %%
  40. %% Change Log;
  41. %% o    (October 2, 88)
  42. %%     Fixed the problem of \line (\@sline). When both x and y are
  43. %%     large, it produced 'bad character code' error.
  44. %%
  45. %% o    (January 17, 89)
  46. %%    Add commands \blacken, \whiten, \shade, \texture
  47. %%
  48. %% o    (January 17, 89)
  49. %%    Add \filltype{xxxxx}
  50. %%    xxxxx - black, white, shade
  51. %%
  52. \typeout{%
  53. Extension to Epic and LaTeX. Version 1.1b - Released Febrary 7, 1988}
  54. %
  55. \newcount\@gphlinewidth
  56. \newcount\@eepictcnt
  57. \newdimen\@tempdimc
  58. \@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736
  59.  
  60. %% Redefine \thinlines, \thicklines
  61. %% See also latex.tex
  62. \def\thinlines{\let\@linefnt\tenln \let\@circlefnt\tencirc
  63.     \@wholewidth\fontdimen8\tenln \@halfwidth .5\@wholewidth
  64.     \@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736\relax}
  65. \def\thicklines{\let\@linefnt\tenlnw \let\@circlefnt\tencircw
  66.     \@wholewidth\fontdimen8\tenlnw \@halfwidth .5\@wholewidth
  67.     \@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736
  68.     \advance\@gphlinewidth\@ne   % Make the output looks better
  69.     \relax}
  70. %%
  71. %% To indicate whether the dot character is defined in the dotted join
  72. %%     environment or not (\@ifnodotdef)
  73. \newif\if@nodotdef \global\@nodotdeftrue
  74. %%
  75. %% Redefine \dottedjoin
  76. \def\dottedjoin{\global\@jointhemtrue \global\@joinkind=0\relax
  77.   \bgroup\@ifnextchar[{\global\@nodotdeffalse\@idottedjoin}%
  78.                       {\global\@nodotdeftrue\@idottedjoin[\@empty]}}
  79. %%----------------------------------------------------------------------
  80. %% Redefine \jput
  81. \long\def\jput(#1,#2)#3{\@killglue\raise#2\unitlength\hbox to \z@{\hskip
  82. #1\unitlength #3\hss}%
  83. \if@jointhem \if@firstpoint \gdef\x@one{#1} \gdef\y@one{#2} \global\@firstpointfalse
  84.  \else\ifcase\@joinkind
  85.     \if@nodotdef
  86.         \@spdottedline{\dotgap@join\unitlength}%
  87. (\x@one\unitlength ,\y@one\unitlength)(#1\unitlength,#2\unitlength)
  88.     \else
  89.     \@dottedline[\dotchar@join]{\dotgap@join\unitlength}%
  90. (\x@one\unitlength,\y@one\unitlength)(#1\unitlength,#2\unitlength)
  91.     \fi
  92.     \or\@dashline[\dashlinestretch]{\dashlen@join\unitlength}[\dotgap@join]%
  93. (\x@one,\y@one)(#1,#2)
  94.     \else\@drawline[\drawlinestretch](\x@one,\y@one)(#1,#2)\fi
  95.     \gdef\x@one{#1}\gdef\y@one{#2}%
  96.  \fi
  97. \fi\ignorespaces}
  98. %%
  99. %% Redefine \dottedline to generate special whenever possible.
  100. \def\dottedline{\@ifnextchar [{\@idottedline}{\@ispdottedline}}
  101. %% Similar to \@idottedline but it generate \special
  102. \def\@ispdottedline#1(#2,#3){\@ifnextchar (%
  103. {\@iispdottedline{#1}(#2,#3)}{\relax}}
  104. \def\@iispdottedline#1(#2,#3)(#4,#5){\@spdottedline{#1\unitlength}%
  105. (#2\unitlength,#3\unitlength)(#4\unitlength,#5\unitlength)%
  106. \@ispdottedline{#1}(#4,#5)}
  107. %
  108. \def\@spdottedline#1(#2,#3)(#4,#5){%
  109.     \@tempcnta \@gphlinewidth\relax
  110.     \advance\@tempcnta by 2     % solely for better output
  111.     \special{pn \the\@tempcnta}%
  112.     \@tempdimc=#2\relax
  113.     \@tempcnta \@tempdimc\relax \advance\@tempcnta 2368 \divide\@tempcnta 4736
  114.     \@tempdimc=#3\relax
  115.     \@tempcntb -\@tempdimc\relax\advance\@tempcntb -2368 \divide\@tempcntb 4736
  116.     \@paspecial{\the\@tempcnta}{\the\@tempcntb}%
  117.     \@tempdimc=#4\relax
  118.     \@tempcnta \@tempdimc\relax \advance\@tempcnta 2368 \divide\@tempcnta 4736
  119.     \@tempdimc=#5\relax
  120.     \@tempcntb -\@tempdimc\relax\advance\@tempcntb -2368 \divide\@tempcntb 4736
  121.     \@paspecial{\the\@tempcnta}{\the\@tempcntb}%
  122.     \@tempdimc=#1\relax
  123. %%
  124. %% Generate the pen width in terms of inch with 3 decimal digit.
  125.     \@tempcnta \@tempdimc\relax \advance\@tempcnta 2368 \divide\@tempcnta 4736
  126. %% \@tempcnta contain the pen width in terms of thousandth of a inch
  127. %% Then it is converted back to inch. I know the way I use is dumb but
  128. %% I cannot think of any better method
  129.     \@tempcntb \@tempcnta\relax \divide\@tempcntb 1000
  130.     \multiply \@tempcntb 1000 \advance\@tempcnta -\@tempcntb
  131.     \divide\@tempcntb 1000
  132.     \ifnum\@tempcnta < 10
  133.         \special{dt \the\@tempcntb.00\the\@tempcnta}%
  134.     \else\ifnum\@tempcnta < 100
  135.         \special{dt \the\@tempcntb.0\the\@tempcnta}%
  136.     \else
  137.         \special{dt \the\@tempcntb.\the\@tempcnta}%
  138.     \fi\fi
  139.     \ignorespaces
  140. }
  141. %
  142. \def\@iiidashline[#1]#2[#3](#4,#5)(#6,#7){%
  143. \@dashline[#1]{#2\unitlength}[#3](#4,#5)(#6,#7)%
  144. \@iidashline[#1]{#2}[#3](#6,#7)}
  145. %
  146. %% Redefine \@dashline
  147. \long\def\@dashline[#1]#2[#3](#4,#5)(#6,#7){{%
  148. \x@diff=#6\unitlength \advance\x@diff by -#4\unitlength
  149. \y@diff=#7\unitlength \advance\y@diff by -#5\unitlength
  150. %% correction to get actual width since the dash-length as taken in arguement
  151. %% is the center-to-center of the end-points.
  152. \@tempdima=#2\relax \advance\@tempdima -\@wholewidth
  153. \sqrtandstuff{\x@diff}{\y@diff}{\@tempdima}%
  154. \ifnum\num@segments <3 \num@segments=3\fi% min number of dashes I can plot
  155. % is 2, 1 at either end, thus min num@segments is 3 (including 'empty dash').
  156. \@tempdima=\x@diff \@tempdimb=\y@diff
  157. \divide\@tempdimb by\num@segments
  158. \divide\@tempdima by\num@segments
  159. %% ugly if-then-else. If optional dotgap specified, then use it otherwise
  160. %% make a solid dash.
  161. {\ifx#3\@empty \relax
  162.     \ifdim\@tempdima < 0pt \x@diff=-\@tempdima\else\x@diff=\@tempdima\fi
  163.     \ifdim\@tempdimb < 0pt \y@diff=-\@tempdimb\else\y@diff=\@tempdimb\fi
  164.     \global\setbox\@dotbox\hbox{%
  165.                 \@absspdrawline(0pt,0pt)(\@tempdima,\@tempdimb)}%
  166.     \else\global\setbox\@dotbox\hbox{%
  167.         \@spdottedline{#3\unitlength}(0pt,0pt)(\@tempdima,\@tempdimb)}%
  168.     \fi}%
  169. \advance\x@diff by -\@tempdima % both have same sign
  170. \advance\y@diff by -\@tempdimb
  171. %
  172. %%here we correct the number of dashes to be put by reducing them
  173. %%appropriately. (num@segments*\@wholewidth) is in some way the slack we
  174. %%have,and division by dash-length gives the reduction. reduction =
  175. %%(2*num@segments*\@wholewidth)/dash-length
  176. %% (num@segments includes empty ones)
  177. \@tempdima=\num@segments\@wholewidth \@tempdima=2\@tempdima
  178. \@tempcnta\@tempdima\relax \@tempdima=#2\relax \@tempdimb=0.5\@tempdima
  179. \@tempcntb\@tempdimb\relax \advance\@tempcnta by \@tempcntb % round-off error
  180. \divide\@tempcnta by\@tempdima \advance\num@segments by -\@tempcnta
  181. %
  182. \ifnum #1=0 \relax\else\ifnum #1 < -100
  183.   \typeout{***dashline: reduction > -100 percent implies blankness!***}
  184. \else\num@segmentsi=#1 \advance\num@segmentsi by 100
  185.      \multiply\num@segments by\num@segmentsi \divide\num@segments by 100
  186. \fi\fi
  187. %
  188. \divide\num@segments by 2 % earlier num@segments included 'empty dashes' too.
  189. \ifnum\num@segments >0 % if =0 then don't divide => \x@diff & \y@diff
  190.  \divide\x@diff by\num@segments%   remain same.
  191.  \divide\y@diff by\num@segments
  192.  \advance\num@segments by\@ne %for the last segment for which I subtracted
  193.                   %\@tempdima & \@tempdimb from \x@diff & \y@diff
  194.  \else\num@segments=2 % one at each end.
  195. \fi
  196. %%\typeout{num@segments finally = \the\num@segments}
  197. %% equiv to \multiput(#4,#5)(\x@diff,\y@diff){\num@segments}{\copy\@dotbox}
  198. %% with arguements in absolute dimensions.
  199. \@xdim=#4\unitlength \@ydim=#5\unitlength
  200. \@killglue
  201. \loop \ifnum\num@segments > 0
  202. \unskip\raise\@ydim\hb