Debian Codegraph @

texmf-dist/metapost/shapes/shapes.mp

raw
1 %%
2 %% This is file `shapes.mp',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% shapes.dtx (with options: `package')
8 %% This is a generated file.
9 %%
10 %% This document is copyright 2015 by Donald P. Goodman, and is
11 %% released publicly under the LaTeX Project Public License. The
12 %% distribution and modification of this work is constrained by the
13 %% conditions of that license. See
14 %% http://www.latex-project.org/lppl.txt
15 %% for the text of the license. This document is released
16 %% under version 1.3 of that license, and this work may be distributed
17 %% or modified under the terms of that license or, at your option, any
18 %% later version.
19 %%
20 %% This work has the LPPL maintenance status 'maintained'.
21 %%
22 %% The Current Maintainer of this work is Donald P. Goodman
23 %% ([email protected]).
24 %%
25 %% This work consists of the files shapes.dtx and
26 %% shapes.ins, along with the generated file shapes.mp
27 %% and shapes.pdf, and the README.
28
29 color fracfillcolor; fracfillcolor := red;
30 pen fraccirclepen; fraccirclepen := pencircle scaled 1.5;
31 pen fractionpen; fractionpen := pencircle scaled 1;
32 def fraccirc(suffix x)(expr y) =
33 radius := 1in;
34 ticklen := radius/24;
35 path circ; circ := fullcircle scaled radius;
36 pair p[]; pair q[]; pair r[]; pair s[];
37 p[0] := (0,0) shifted (0,radius/2);
38 q[0] := p[0] shifted (0,ticklen);
39 r[0] := p[0] shifted (0,-ticklen);
40 s[0] := r[0];
41 picture thefrac;
42 picture addition;
43 thefrac := image(pickup fraccirclepen; draw circ;);
44 addition := image(pickup fractionpen; draw p[0]--q[0];);
45 addto thefrac also addition;
46 for i=1 upto 12:
47 p[i] := p[i-1] rotatedaround ((0,0),-30);
48 q[i] := q[i-1] rotatedaround ((0,0),-30);
49 addition := image(pickup fractionpen; draw p[i]--q[i];);
50 addto thefrac also addition;
51 endfor;
52 addition := image(pickup fractionpen; draw (0,0)--r[0];);
53 addto thefrac also addition;
54 pair t; pair q;
55 addition := image(
56 t = r[0] rotatedaround ((0,0),-((360/y)*x)/2);
57 q = r[0] rotatedaround ((0,0),-((360/y)*x));
58 fill r[0]--(0,0)--q..t..cycle withcolor fracfillcolor;
59 draw r[0]--(0,0)--q..t..cycle;
60 );
61 addto thefrac also addition;
62 for i=1 upto y:
63 r[i] := r[i-1] rotatedaround ((0,0),-(360/y));
64 s[i] := r[i-1] rotatedaround ((0,0),-(360/y)/2);
65 addition := image(%
66 pickup fractionpen;%
67 draw (0,0)--r[i];
68 draw r[i-1]..s[i]..r[i];
69 );
70 addto thefrac also addition;
71 endfor;
72 enddef;
73 boolean modcircle; modcircle := true;
74 pen modcirclepen; modcirclepen := pencircle scaled 1;
75 pen modshapepen; modshapepen := pencircle scaled 1;
76 boolean modticks; modticks := false;
77 numeric nummodticks; nummodticks := 12;
78 numeric ticklen; ticklen := 0.1in;
79 pen tickpen; tickpen := pencircle scaled 1;
80 def modstar(expr numpoints,numbers,numstar) =
81 picture modfigure;
82 if (modcircle = true):
83 modfigure := image(draw fullcircle scaled 1in withpen modcirclepen;);
84 else:
85 modfigure := image();
86 fi;
87 picture modtickpic;
88 if (modticks = true):
89 modtickpic := image(
90 pair tickstart[]; pair tickend[];
91 tickstart[0] = (0,0) shifted (0,0.5in);
92 tickend[0] = tickstart[0] shifted (0,ticklen);
93 draw tickstart[0]--tickend[0] withpen tickpen;
94 for i=1 upto (nummodticks-1):
95 tickstart[i] = tickstart[i-1] rotatedaround
96 ((0,0), (360/nummodticks));
97 tickend[i] = tickend[i-1] rotatedaround
98 ((0,0), (360/nummodticks));
99 draw tickstart[i]--tickend[i] withpen tickpen;
100 endfor;
101 );
102 addto modfigure also modtickpic;
103 fi
104 pickup modshapepen;
105 pair p[]; pair q[];
106 picture addition;
107 p[0] = (0,0.5in);
108 q[0] = (0,0.6in);
109 if (numbers = 1):
110 addition := image(label("0",q[0]));
111 addto modfigure also addition;
112 fi
113 for i=1 upto numpoints:
114 p[i] = p[i-1] rotatedaround ((0,0),-(360/numpoints));
115 q[i] = q[i-1] rotatedaround ((0,0),-(360/numpoints));
116 if (numbers = 1):
117 if (i <> numpoints):
118 addition := image(label(decimal i,q[i]));
119 addto modfigure also addition;
120 fi
121 fi
122 endfor
123 for i=0 upto numpoints:
124 if (i < numstar):
125 addition := image(%
126 draw p[i]--p[i+numstar];
127 draw p[i]--p[numpoints - numstar + i];
128 );
129 addto modfigure also addition;
130 elseif (i >= (numstar*2)):
131 addition := image(draw p[i-numstar]--p[i]);
132 addto modfigure also addition;
133 fi
134 endfor
135 addto modfigure also addition;
136 enddef;
137 def modfig(expr numpoints,numbers) =
138 picture modfigure;
139 if (modcircle = true):
140 modfigure := image(draw fullcircle scaled 1in withpen modcirclepen);
141 else:
142 modfigure := image();
143 fi
144 picture modtickpic;
145 if (modticks = true):
146 modtickpic := image(
147 pair tickstart[]; pair tickend[];
148 tickstart[0] = (0,0) shifted (0,0.5in);
149 tickend[0] = tickstart[0] shifted (0,ticklen);
150 draw tickstart[0]--tickend[0] withpen tickpen;
151 for i=1 upto (nummodticks-1):
152 tickstart[i] = tickstart[i-1] rotatedaround
153 ((0,0), (360/nummodticks));
154 tickend[i] = tickend[i-1] rotatedaround
155 ((0,0), (360/nummodticks));
156 draw tickstart[i]--tickend[i] withpen tickpen;
157 endfor;
158 );
159 addto modfigure also modtickpic;
160 fi
161 pair p[]; pair q[];
162 picture addition;
163 pickup modshapepen;
164 p[0] = (0,0.5in);
165 q[0] = (0,0.6in);
166 if (numbers = 1):
167 addition := image(label("0",q[0]));
168 addto modfigure also addition;
169 fi
170 for i=1 upto numpoints:
171 p[i] = p[i-1] rotatedaround ((0,0),-(360/numpoints));
172 q[i] = q[i-1] rotatedaround ((0,0),-(360/numpoints));
173 addition := image(draw p[i-1]--p[i]);
174 addto modfigure also addition;
175 if (numbers = 1):
176 if (i <> numpoints):
177 addition := image(label(decimal i,q[i]));
178 addto modfigure also addition;
179 fi
180 fi
181 endfor;
182 enddef;
183 \endinput
184 %%
185 %% End of file `shapes.mp'.