summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/metapost
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-08-02 21:30:22 +0000
committerKarl Berry <karl@freefriends.org>2015-08-02 21:30:22 +0000
commitc4cbbdc6c246816defebc2afa9fd9b82b42118e3 (patch)
tree478c48d21c8f6bd82b7520f146168e9db82bc56c /Master/texmf-dist/source/metapost
parent008ccd78c7a2d5abf3e17cb872cf1536f6192ecb (diff)
shapes (2aug15)
git-svn-id: svn://tug.org/texlive/trunk@38024 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/metapost')
-rw-r--r--Master/texmf-dist/source/metapost/shapes/shapes.dtx69
1 files changed, 69 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/metapost/shapes/shapes.dtx b/Master/texmf-dist/source/metapost/shapes/shapes.dtx
index ab1b14cfb28..9a7c4b2125a 100644
--- a/Master/texmf-dist/source/metapost/shapes/shapes.dtx
+++ b/Master/texmf-dist/source/metapost/shapes/shapes.dtx
@@ -193,6 +193,37 @@
% Both |modcirclepen| and |modshapepen| default to
% |pencircle scaled 1|.
%
+% We can also put ticks around the outside of the circle,
+% at whatever intervals we want. The parameters here are
+% \DescribeMacro{modticks}|modticks|, which is a boolean set
+% to |false| by default. Set it to |true| if you want
+% ticks. You can control the number of ticks with
+% \DescribeMacro{nummodticks}|nummodticks|, which defaults
+% to twelve. You can control the length of those ticks with
+% \DescribeMacro{ticklen}|ticklen|, which defaults to
+% |0.1in|. Finally, you can control the pen that is used to
+% draw the ticks, which is \DescribeMacro{tickpen}|tickpen|,
+% which defaults to |pencircle scaled 1|:
+%
+% \demonstrate{%
+% \hbox{|nummodticks := 6;|}
+% \hbox{|ticklen := 0.2in;|}
+% \hbox{|modticks := true;|}
+% \hbox{|tickpen := pensquare scaled 2;|}
+% \hbox{|modshapepen := pensquare scaled 4;|}
+% \hbox{|modfig(4,0);|}
+% \hbox{|draw modfigure;|}
+% }{%
+% \begin{mpost}
+% nummodticks := 6;
+% ticklen := 0.2in;
+% modticks := true;
+% tickpen := pensquare scaled 2;
+% modshapepen := pensquare scaled 4;
+% modfig(4,0); draw modfigure;
+% \end{mpost}
+% }%
+%
% We can do essentially the same thing with reentrant star
% figures with |modstar|. Unlike |modfig|, |modstar| takes
% \emph{three} arguments: the number of vertices, whether
@@ -330,6 +361,10 @@ enddef;
boolean modcircle; modcircle := true;
pen modcirclepen; modcirclepen := pencircle scaled 1;
pen modshapepen; modshapepen := pencircle scaled 1;
+boolean modticks; modticks := false;
+numeric nummodticks; nummodticks := 12;
+numeric ticklen; ticklen := 0.1in;
+pen tickpen; tickpen := pencircle scaled 1;
def modstar(expr numpoints,numbers,numstar) =
picture modfigure;
if (modcircle = true):
@@ -337,6 +372,23 @@ def modstar(expr numpoints,numbers,numstar) =
else:
modfigure := image();
fi;
+ picture modtickpic;
+ if (modticks = true):
+ modtickpic := image(
+ pair tickstart[]; pair tickend[];
+ tickstart[0] = (0,0) shifted (0,0.5in);
+ tickend[0] = tickstart[0] shifted (0,ticklen);
+ draw tickstart[0]--tickend[0] withpen tickpen;
+ for i=1 upto (nummodticks-1):
+ tickstart[i] = tickstart[i-1] rotatedaround
+ ((0,0), (360/nummodticks));
+ tickend[i] = tickend[i-1] rotatedaround
+ ((0,0), (360/nummodticks));
+ draw tickstart[i]--tickend[i] withpen tickpen;
+ endfor;
+ );
+ addto modfigure also modtickpic;
+ fi
pickup modshapepen;
pair p[]; pair q[];
picture addition;
@@ -377,6 +429,23 @@ def modfig(expr numpoints,numbers) =
else:
modfigure := image();
fi
+ picture modtickpic;
+ if (modticks = true):
+ modtickpic := image(
+ pair tickstart[]; pair tickend[];
+ tickstart[0] = (0,0) shifted (0,0.5in);
+ tickend[0] = tickstart[0] shifted (0,ticklen);
+ draw tickstart[0]--tickend[0] withpen tickpen;
+ for i=1 upto (nummodticks-1):
+ tickstart[i] = tickstart[i-1] rotatedaround
+ ((0,0), (360/nummodticks));
+ tickend[i] = tickend[i-1] rotatedaround
+ ((0,0), (360/nummodticks));
+ draw tickstart[i]--tickend[i] withpen tickpen;
+ endfor;
+ );
+ addto modfigure also modtickpic;
+ fi
pair p[]; pair q[];
picture addition;
pickup modshapepen;