这个问题可能很简单,但我需要你的帮助,画一个全彩色的三角形和圆圈(三角形位于圆圈内)。
这是我的文件pic_1.mp
:
input gjktc.mp;
u:=1mm;
beginfig(1);
z0=(0,0);
z1=(20u,0);
z2=(10u,20u);
draw z0..z1..z2..cycle withcolor green;
draw z0--z1--z2--cycle withcolor red;
endfig;
end;
下一个是pic_2.mp
,其中一条线将被旋转,并且线之间的空间将被着色:
input gjktc.mp;
u:=1mm;
beginfig(1);
z0=(0,0);
z1=(20u,0);
z2=(10u,10u);
p1 = z0--z1--z2--cycle ;
draw p1 withcolor black;
draw (z2--z0) rotated 5 withcolor black;
endfig;
end;
这是我想要的图片:
答案1
prologues := 3; % Make metapost write EPS files
u := 1mm;
outputtemplate := "pic%c.eps"; % set the filename template - %c picks up the fig #
beginfig(1);
z0=(10u,0) rotated 90; % use "rotated" to get a nice equilateral triangle easily
z1=z0 rotated 120; z2 = z0 rotated -120;
fill z0..z1..z2..cycle withcolor green;
fill z0--z1--z2--cycle withcolor red;
endfig;
beginfig(2); % second fig can be in the same file
z0=(0,0);
z1=(20u,0);
z2=(10u,10u);
z3 = whatever[z0,z2 rotated 5] = whatever[z1,z2]; % read mpman.pdf for "whatever"
path p[]; % you must declare paths
p1 = z0--z1--z2--cycle;
p2 = z0--z2--z3--cycle;
fill p1 withcolor green; % fill before you draw (in general)
fill p2 withcolor red;
draw p1 withcolor black;
draw p2 withcolor black;
endfig;
end;
我在代码中添加了一些注释。
图片1.eps = 图片2.eps =