summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/shapes/shapes.mp
blob: 33b20ddd3d7f04515f1f168ae920cb7cd1c6c921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
%%
%% This is file `shapes.mp',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% shapes.dtx  (with options: `package')
%% This is a generated file.
%% 
%% This document is copyright 2015 by Donald P. Goodman, and is
%% released publicly under the LaTeX Project Public License.  The
%% distribution and modification of this work is constrained by the
%% conditions of that license.  See
%% http://www.latex-project.org/lppl.txt
%% for the text of the license.  This document is released
%% under version 1.3 of that license, and this work may be distributed
%% or modified under the terms of that license or, at your option, any
%% later version.
%% 
%% This work has the LPPL maintenance status 'maintained'.
%% 
%% The Current Maintainer of this work is Donald P. Goodman
%% (dgoodmaniii@gmail.com).
%% 
%% This work consists of the files shapes.dtx and
%% shapes.ins, along with the generated file shapes.mp
%% and shapes.pdf, and the README.

color fracfillcolor; fracfillcolor := red;
pen fraccirclepen; fraccirclepen := pencircle scaled 1.5;
pen fractionpen; fractionpen := pencircle scaled 1;
def fraccirc(suffix x)(expr y) =
radius := 1in;
ticklen := radius/24;
path circ; circ := fullcircle scaled radius;
pair p[]; pair q[]; pair r[]; pair s[];
p[0] := (0,0) shifted (0,radius/2);
q[0] := p[0] shifted (0,ticklen);
r[0] := p[0] shifted (0,-ticklen);
s[0] := r[0];
picture thefrac;
picture addition;
thefrac := image(pickup fraccirclepen; draw circ;);
addition := image(pickup fractionpen; draw p[0]--q[0];);
addto thefrac also addition;
for i=1 upto 12:
p[i] := p[i-1] rotatedaround ((0,0),-30);
q[i] := q[i-1] rotatedaround ((0,0),-30);
addition := image(pickup fractionpen; draw p[i]--q[i];);
addto thefrac also addition;
endfor;
addition := image(pickup fractionpen; draw (0,0)--r[0];);
addto thefrac also addition;
pair t; pair q;
addition := image(
t = r[0] rotatedaround ((0,0),-((360/y)*x)/2);
q = r[0] rotatedaround ((0,0),-((360/y)*x));
fill r[0]--(0,0)--q..t..cycle withcolor fracfillcolor;
draw r[0]--(0,0)--q..t..cycle;
);
addto thefrac also addition;
for i=1 upto y:
r[i] := r[i-1] rotatedaround ((0,0),-(360/y));
s[i] := r[i-1] rotatedaround ((0,0),-(360/y)/2);
addition := image(%
pickup fractionpen;%
draw (0,0)--r[i];
draw r[i-1]..s[i]..r[i];
);
addto thefrac also addition;
endfor;
enddef;
boolean modcircle; modcircle := true;
pen modcirclepen; modcirclepen := pencircle scaled 1;
pen modshapepen; modshapepen := pencircle scaled 1;
def modstar(expr numpoints,numbers,numstar) =
picture modfigure;
if (modcircle = true):
modfigure := image(draw fullcircle scaled 1in withpen modcirclepen;);
else:
modfigure := image();
fi;
pickup modshapepen;
pair p[]; pair q[];
picture addition;
p[0] = (0,0.5in);
q[0] = (0,0.6in);
if (numbers = 1):
addition := image(label("0",q[0]));
addto modfigure also addition;
fi
for i=1 upto numpoints:
p[i] = p[i-1] rotatedaround ((0,0),-(360/numpoints));
q[i] = q[i-1] rotatedaround ((0,0),-(360/numpoints));
if (numbers = 1):
if (i <> numpoints):
addition := image(label(decimal i,q[i]));
addto modfigure also addition;
fi
fi
endfor
for i=0 upto numpoints:
if (i < numstar):
addition := image(%
draw p[i]--p[i+numstar];
draw p[i]--p[numpoints - numstar + i];
);
addto modfigure also addition;
elseif (i >= (numstar*2)):
addition := image(draw p[i-numstar]--p[i]);
addto modfigure also addition;
fi
endfor
addto modfigure also addition;
enddef;
def modfig(expr numpoints,numbers) =
picture modfigure;
if (modcircle = true):
modfigure := image(draw fullcircle scaled 1in withpen modcirclepen);
else:
modfigure := image();
fi
pair p[]; pair q[];
picture addition;
pickup modshapepen;
p[0] = (0,0.5in);
q[0] = (0,0.6in);
if (numbers = 1):
addition := image(label("0",q[0]));
addto modfigure also addition;
fi
for i=1 upto numpoints:
p[i] = p[i-1] rotatedaround ((0,0),-(360/numpoints));
q[i] = q[i-1] rotatedaround ((0,0),-(360/numpoints));
addition := image(draw p[i-1]--p[i]);
addto modfigure also addition;
if (numbers = 1):
if (i <> numpoints):
addition := image(label(decimal i,q[i]));
addto modfigure also addition;
fi
fi
endfor;
enddef;
\endinput
%%
%% End of file `shapes.mp'.