没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
MetaPost: A Very Brief Tutorial
osurs@bluewin.ch Urs Oswald http://www.ursoswald.ch
October 3, 2002
Contents
1 A2B 2
2 LineSegments 3
3 Circles 4
4 CircleParametrization 5
5 BezierCurves 7
6 GraphSqrt 8
7 Paths 9
8 StringLabels 11
9 TeXLabels 13
10 LaTeXLabels 15
11 Equations 17
12 Mediation 19
13 Precedence 21
14 Directions 23
15 Times 25
16 Colors 27
17 Slanted 28
18 Scaled 30
19 xScaled 33
20 zScaled 35
21 Transform 38
22 Functions 41
23 ForSuffixes 43
24 Recursiveness 47
25 RecursivePath 48
26 ifthenInLabel 50
27 NewOperators 52
1
1 A2B
beginfig(1)
draw (100, 100)--(350, 275);
endfig;
end
2
2 LineSegments
u:=25; % 25 = 25bp = 25 PostScript points = 25/72 in
wi:=10; % width in units u
he:=7; % height in units u
hoehe:=he*u; % height
breite:=wi*u; % width
beginfig(1)
% --- Grid ---
for i=0 upto he:
draw (0, i*u)--(breite, i*u) withcolor .7white;
endfor
for j=0 upto wi:
draw (j*u, 0)--(j*u, hoehe) withcolor .7white;
endfor
% --- End Grid ---
draw (0, 0)--(breite, 0)--(breite, hoehe)--(0, hoehe)--cycle;
% --- Line Segment ---
draw (.7u, 4u)--(5u, 6.5u);
% --- Arrow ---
drawarrow (6.4u, 6u)--(9.5u, 4.8u);
pickup pencircle scaled 2; % default:
% 0.5 (= 0.5bp = 0.5 PostScript Points)
% --- Polyline ---
draw (u, 5u)--(0, 4u)--(u, 3u)--(2u, 4u)--(3u, 3u)--(u,u)--(2u, 0)--(3u, u);
% --- Polyarrow ---
drawarrow (5u, 5u)--(4u, 3u)--(5u, 4u)--(4u, 2u)--(6u, 3u)--(5u, u);
% --- Polygon ---
fill (7.7u, .3u)--(9.6u, 1.5u)--(9.3u, 3.6u)--(7.2u, 3.8u)
--(6.4u, 2.5u)--(7.3u, 1.9u)--cycle withcolor .9white;
pickup pencircle scaled .5;
draw (7.7u, .3u)--(9.6u, 1.5u)--(9.3u, 3.6u)--(7.2u, 3.8u)
--(6.4u, 2.5u)--(7.3u, 1.9u)--cycle;
endfig;
end
3
3 Circles
%
% /home/osurs/latex/metapost/TutorialAugsburg/tutorial/Circles/Circles.mp
% 18.09.02
%
u:=25; % 25 = 25bp = 25 PostScript points = 30/72 in
wi:=10; % width in units u
he:=7; % height in units u
hoehe:=he*u; % height
breite:=wi*u; % width
beginfig(1)
% --- Grid ---
for i=0 upto he:
draw (0, i*u)--(breite, i*u) withcolor .7white;
endfor
for j=0 upto wi:
draw (j*u, 0)--(j*u, hoehe) withcolor .7white;
endfor
% --- End Grid ---
draw (0, 0)--(breite, 0)--(breite, hoehe)--(0, hoehe)--cycle;
%%% %%%
%%% fullcircle %%%
%%% halfcircle %%%
%%% %%%
draw fullcircle scaled 3u shifted (5u, 5.2u);
draw fullcircle xscaled 3u yscaled 1.2u shifted (5u, 2.2u);
draw fullcircle xscaled 1.2u yscaled 3u shifted (8u, 5.2u);
fill fullcircle xscaled 3u yscaled 1.2u rotated 45 shifted (8u, 2.2u) withcolor .9white;
draw fullcircle xscaled 3u yscaled 1.2u rotated 45 shifted (8u, 2.2u);
draw halfcircle scaled 2u shifted (1.5u, 5u);
pickup pencircle scaled 1.5;
draw halfcircle scaled 2u rotated 90 shifted (1.5u, 4u) withcolor red;
draw halfcircle scaled 2u rotated -90 shifted (1.5u, 3u) withcolor blue;
endfig;
end
4
4 CircleParametrization
t = 0
t = 1
point 2 of p0
t = 3
4
t = 5
6
t = 7
p0
length(p0)=8
t = 0
t = 1 - p oint 1 of p1
t = 2
t = 3
t = 4
t = 5
t = 6
t = 7
p1
subpath (0, 4) of p2
subpath (4, 8) of p2
p3
u:=25; % 25 = 25bp = 25 PostScript points = 25/72 in
wi:=10; % width in units u
he:=7; % height in units u
hoehe:=he*u; % height
breite:=wi*u; % width
path p[];
p0:=fullcircle scaled 3u shifted (2.3u, hoehe-2.1u);
p1:=fullcircle xscaled 3u yscaled u rotated 225 shifted (2.3u, 1.6u);
p2:=fullcircle xscaled 4u yscaled 2u shifted (7.25u, hoehe/2);
p3:=fullcircle xscaled 5u yscaled 6.5u shifted (7.25u, hoehe/2);
def draw_point(expr P, colInt, colPer) =
fill fullcircle scaled 1.5mm shifted P withcolor colInt;
draw fullcircle scaled 1.5mm shifted P withcolor colPer;
enddef;
beginfig(1)
% --- Draw frame ---
draw (0, 0)--(breite, 0)--(breite, hoehe)--(0, hoehe)--cycle;
draw p0; % Draw p0
pickup pencircle scaled 1.5;
draw subpath (0, 4) of p0 withcolor red;
pickup pencircle scaled 0.5;
for t=0 upto 7:
z[t]=point t of p0;
draw_point(z[t], white, red);
if (t<2) or (t=7):
label.rt("t = "&decimal t, z[t]);
elseif t=2:
label.top("point "&decimal t&" of p0", z[t]);
elseif (t=3) or (t=5):
label.lft("t = "&decimal t, z[t]);
elseif t=4:
label.lft(decimal t, z[t]);
else:
label.ulft(decimal t, z[t]);
fi
endfor
label("p0", center p0 + (0, .25u));
label("length(p0)="&decimal length(p0), center p0 - (0, .25u));
5
剩余52页未读,继续阅读
资源评论
- wsntdylan2014-02-27确实比较实用,但会存在很多基础问题
songjinghe
- 粉丝: 2
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功