我怎样才能填充 p2 和 p3 之间的区域?我尝试使用buildcycle
宏,但没有用。
path p[];
p1 = fullcircle xscaled 1.2in yscaled 0.6in;
p2 = (-1cm, 0)..(0cm, -0.2cm)..(1cm, 0) shifted up;
p3 = p2 rotatedaround(center p1, 180) shifted down cutbefore p2 cutafter p2;
fill buildcycle(p2, p3) withcolor red;
draw p1 scaled 1.2; draw p2 scaled 1.2;
draw p3 scaled 1.2;
答案1
buildcycle
在修剪之前使用p3
- 否则它们不会重叠,正如错误消息所说的那样。
这是一个包含其他一些建议的优化的版本。
prologues := 3;
outputtemplate := "%j%c.%{outputformat}";
beginfig(1);
path p[];
p1 = fullcircle xscaled 1.2in yscaled 0.6in;
p2 = (-1cm, 0)..(0cm, -0.2cm)..(1cm, 0) shifted up;
p3 = p2 rotatedaround(center p1, 180) shifted down;
% scale all the paths
for i=1,2,3: p[i] := p[i] scaled 2; endfor
% now make the path round the middle
fill buildcycle(p2, p3) withcolor red;
% now trim the upper path
p3 := p3 cutbefore p2 cutafter p2;
% finally draw them all.
draw p1;
draw p2;
draw p3;
endfig;
end.
使用 进行编译mpost
,然后使用epstopdf
或类似的工具来获得以下内容:
答案2
fill buildcycle(reverse p2, p3) scaled 1.2 withcolor red;