13-Apr-88 21:17:28-PDT,11449;000000000000
Return-Path:
Date: Wed, 13 Apr 88 21:22:46 PDT
From: kwok@iris.ucdavis.edu (Conrad Kwok)
Subject: macros for use with LaTeX picture environment.
The macros are for use with LaTeX picture environment.
They modify \circle and \line to allows you to draw circle
of any size and line with any slope and any length.
Commands for drawing \ellipse and \arc are provided also.
A new command for setting line width \Thicklines is included.
The command affects line width for circle, ellipse and line too.
Details can be found in the READ.ME file.
--Conrad
---------------------Cut Here----------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# READ.ME
# spgraph.tex
# testgph.tex
# This archive created: Mon Apr 11 10:48:00 1988
export PATH; PATH=/bin:$PATH
if test -f 'READ.ME'
then
echo shar: will not over-write existing file "'READ.ME'"
else
sed 's/^X//' << \SHAR_EOF > 'READ.ME'
X
X SpGraph Version 0.0
X
X Written by Conrad Kwok
X April 10,1988
X
X All files related to SpGraph are in public domain.
X You may distribute and modify the files in any ways
X you like. The files are provided as is. I provide
X absolutely no warranty of any kind.
X
XSpGraph is a macro file for use with the LaTeX picture environment.
XIt is much less powerful but much faster than PiCTeX. Another
Xadvantage is that the macros are compatible with LaTeX. You
Xdon't have to learn anything new if you already know how to use LaTeX.
XThe macros generate \special commands for drawing lines, circles,
Xellipsis and circular arc at any line width. Since they generate
X\special commands, you need to have a cmpatible dvi-to-printer program.
X
XThe \special commands they generated are subset of commands used by
Xtpic (tpic is a pic like program for use with TeX). If your site
Xsupports tpic, you will definitely be able to use it. If not,
Xyou have to check the dvi-to-printer program you are using by running
Xthe test program (testgph.tex) included.
X
XMany of the new dvi-to-printer program supports those \special.
XSuch as imagen1, texx and texsun distributed by U. Of Illinois (I
Xthink those programs are currently distributed with TeX82, please
Xlet me know if I am wrong.) and several others written in UC Irvine.
X
XTo use the macros, include the line
X \include spgraph
Xafter the line \documentstyle...
X
XThe macros replace some of the original LaTeX macros but their
Xfunctionalities are extension of the original ones. Hence they
Xshould be transparent to the users unless extended features are
Xused.
X
X
XThe commands \line and \circle are extend in the following ways:
X
X\line You may specify any slope and any length (no minimum length)
X but the two numbers for the slope must still be integers.
X\circle (but not \circle*) Any radii are allowed.
X
XThree new commands are provided.
X
X\ellipse{x}{y}
X Draws ellipse with the x-axis and y-axis length equal to x
Xand y respectively. When x is equal to y. The command is identical to
X\circle{x}.
X
X\arc{r}{s}{e}
X Draws a circular arc. Starting angle is s and ending angle
Xis e. Both are in radian. s must be between 0 and 2*PI. and e > s and
Xmust be less than s + 2*PI. Therefore e could be greater than 2*PI.
XThe point corresponds to angle 0 is the on the right of the center and
Xthe arc is drawn in clockwise direction.
X
X\Thicklines
X Line width is 1.5 times of \thicklines. This also affects
Xthe line width for \line, \circle, \ellipse and \arc.
X
X
X
XBUGS
X1. The two number for specifying the slope of \vector must still
X be between -4 and 4. Although line of any slope can be drawn,
X the head of the arrow still come from the LaTeX fonts. The
X line width of vector is affected by \Thicklines also.
X
X2. The round corners for \oval are still come from the LaTeX
X fonts. When \Thicklines is selected, the width of the
X horizontal and vertical lines will be slightly greater than
X the corners.
X
X
XFurture Directions
X
X1. Extend the \vector command to draw \vector with any slope.
X
X2. Provide new commands for drawing spline, polygon and path as soon as
X I figure out how to write a command that accepts variable
X numbers of arguments. For example \spline{(0,0)(1,3)....(x,y)}
X or \spline{0,0 1,3 . . . . x,y} and similarly for \path and \polygon.
X If any one out there already know how to do this, please
X e-mail me an example. I will appreciate you help.
X
X3. Fix the \oval problem for thicker lines.
X
X4. Provide commands for setting line width.
X
XAll comments, suggestions or bug reports are welcome.
XMy e-mail addresses are:
Xinternet: kwok@iris.ucdavis.edu
Xcsnet: kwok@ucd.csnet
Xcsnet: kwok%iris.ucdavis.edu@csnet.relay
Xuucp: ...ucbvax!ucdavis!iris!kwok
X
SHAR_EOF
fi # end of overwriting check
if test -f 'spgraph.tex'
then
echo shar: will not over-write existing file "'spgraph.tex'"
else
sed 's/^X//' << \SHAR_EOF > 'spgraph.tex'
X% SpGpraph Version 0.0 < April 6, 1988 >
X% Written by Conrad Kwok
X%
X% The macros are in public domain.
X% You may distribute or modify it in any ways you like.
X%
X% You need an dvi-to-printer program that supports the \special
X% commands used by the macros. The commands are subset of the commands
X% used by tpic program. For more information, read the READ.ME file
X%
X% Usage:
X% For LaTeX
X% Include the file after the \documentstyle command by saying
X% \include spgraph
X%
X% For TeX
X% Include the file after including the file latexpicobjs.tex
X% \include latexpicobj
X% \include spgraph
X% in the beginning of the TeX file.
X%
X% The macros are for use with LaTeX picture environment
X% By including the macro file, you can draw
X% 1) \line in any slope
X% 2) \circle with any radius
X% 3) \ellipse with any x-axis and y-axis length
X% 4) Circular \arc by giving starting and ending angle (in radius)
X%
X% Furthermore you may draw lines in any thickness.
X%
X%
X\makeatletter
X
X% Create a new counter to store the line thickness in thousandth of an inch
X\newcount\@gphlinewidth
X\@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736
X
X% Redefine \thinlines, \thicklines and define \Thickline
X% See also latex.tex
X\def\thinlines{\let\@linefnt\tenln \let\@circlefnt\tencirc
X \@wholewidth\fontdimen8\tenln \@halfwidth .5\@wholewidth
X \@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736\relax}
X\def\thicklines{\let\@linefnt\tenlnw \let\@circlefnt\tencircw
X \@wholewidth\fontdimen8\tenlnw \@halfwidth .5\@wholewidth
X \@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736
X \advance\@gphlinewidth\@ne % Make the output looks better
X \relax}
X\def\Thicklines{\let\@linefnt\tenlnw \let\@circlefnt\tencircw
X \@wholewidth\fontdimen8\tenlnw \@wholewidth 1.5\@wholewidth
X \@halfwidth .5\@wholewidth
X \@gphlinewidth\@wholewidth \divide\@gphlinewidth 4736\relax}
X%
X% Generate the \special command for drawing arc
X\def\@circlespecial#1#2#3#4{%
X \special{pn \the\@gphlinewidth}%
X \special{ar 0 0 #1 #2 #3 #4}
X}
X%
X% Command for drawing an arc. Elliptical arc command can be generated
X% but all iptex program I saw so far does not support that.
X\def\@arc#1#2#3#4{%
X% convert TeX dimension to length in terms thousandth of an inch
X \@tempdima #1\unitlength
X \@tempdimb #2\unitlength
X \@tempcnta\@tempdima \advance\@tempcnta 4736 \divide\@tempcnta 9473
X \@tempcntb\@tempdimb \advance\@tempcntb 4736 \divide\@tempcntb 9473
X \setbox\@tempboxa\hbox{%
X \@circlespecial{\the\@tempcnta}{\the\@tempcntb}{#3}{#4}}%
X \wd\@tempboxa\z@ \box\@tempboxa
X}
X%
X% Command for drawing Circle and Ellipse in terms of \@arc
X% replace original \@circle
X\def\@circle#1{\@arc{#1}{#1}{0}{6.2832}}
X\def\ellipse#1#2{\@arc{#1}{#2}{0}{6.2832}}
X\def\arc#1#2#3{\@arc{#1}{#1}{#2}{#3}}
X%
X% Generate \special commands for drawing line
X\def\@linespecial#1#2{%
X \special{pn \the\@gphlinewidth}%
X \special{pa 0 0}%
X \special{pa #1 #2}%
X \special{fp}
X}
X%
X% Replace original \@sline
X% For description, see latex.tex
X\def\@sline{%
X \ifnum\@xarg< 0
X \@negargtrue \@xarg -\@xarg \@tempdima -\@linelen
X \else
X \@negargfalse \@tempdima\@linelen
X \fi
X% truncation is used in arithmetic
X \@tempcnta\@linelen \divide\@tempcnta 4736
X \@yyarg -\@yarg \multiply\@yyarg \@tempcnta \divide\@yyarg\@xarg
X \if@negarg
X \@tempcnta -\@tempcnta
X \fi
X \setbox\@linechar\hbox{\@linespecial{\the\@tempcnta}{\the\@yyarg}}%
X \wd\@linechar\@tempdima
X \@clnht\@linelen
X \multiply\@clnht\@yarg
X \divide\@clnht\@xarg
X \ifnum\@yarg< 0
X \@clnht -\@clnht
X \ht\@linechar\z@ \dp\@linechar\@clnht
X \else
X \ht\@linechar\@clnht \dp\@linechar\z@
X \fi
X \box\@linechar
X% Codes below (till end of the command) is only necessary
X% when used with \@svector
X \if@negarg
X \@yyarg -\@yarg
X \else
X \@yyarg \@yarg
X \fi
X \setbox\@linechar\hbox{\@linefnt\@getlinechar(\@xarg,\@yyarg)}%
X \ifnum\@yarg> 0
X \let\@upordown\raise
X \advance\@clnht -\ht\@linechar
X \else
X \let\@upordown\lower
X \fi
X \if@negarg \kern\wd\@linechar \fi
X}
X%
X\makeatother
X
SHAR_EOF
fi # end of overwriting check
if test -f 'testgph.tex'
then
echo shar: will not over-write existing file "'testgph.tex'"
else
sed 's/^X//' << \SHAR_EOF > 'testgph.tex'
X\documentstyle{article}
X\input spgraph
X\begin{document}
X\verb|\thinlines|
X
X\begin{picture}(100,100)(0,0)
X\thinlines
X\put(50,50){\circle{20}}
X\put(50,50){\circle*{5}}
X\put(50,50){\vector(4,3){20}}
X\put(100,50){\arc{20}{0}{5}}
X\put(100,50){\vector(-4,3){20}}
X\put(150,50){\ellipse{20}{14}}
X\put(150,50){\vector(-4,-3){20}}
X\put(200,50){\ellipse{20}{10}}
X\put(200,50){\vector(4,-3){20}}
X\put(125,50){\oval(230,40)}
X\end{picture}
X
X\bigskip
X\verb|\thicklines|
X
X\begin{picture}(100,100)(0,0)
X\thicklines
X\put(50,50){\circle{20}}
X\put(50,50){\circle*{5}}
X\put(50,50){\vector(4,3){20}}
X\put(100,50){\arc{20}{0}{5}}
X\put(100,50){\vector(-4,3){20}}
X\put(150,50){\ellipse{20}{14}}
X\put(150,50){\vector(-4,-3){20}}
X\put(200,50){\ellipse{20}{10}}
X\put(200,50){\vector(4,-3){20}}
X\put(125,50){\oval(230,40)}
X\end{picture}
X
X\bigskip
X\verb|\Thicklines|
X
X\begin{picture}(100,100)(0,0)
X\Thicklines
X\put(50,50){\circle{20}}
X\put(50,50){\circle*{5}}
X\put(50,50){\vector(4,3){20}}
X\put(100,50){\arc{20}{0}{5}}
X\put(100,50){\vector(-4,3){20}}
X\put(150,50){\ellipse{20}{14}}
X\put(150,50){\vector(-4,-3){20}}
X\put(200,50){\ellipse{20}{10}}
X\put(200,50){\vector(4,-3){20}}
X\put(125,50){\oval(230,40)}
X\end{picture}
X\end{document}
SHAR_EOF
fi # end of overwriting check
# End of shell archive
exit 0