以下是一个最小示例来说明我的问题。我想要hatchfill
Cee 部分。我不知道如何cycle path
为舱口构建。我试过了buildcycle
但失败了。我怎样才能将添加corner radius
到自行车道中?
\documentclass[a4paper]{article}
\usepackage{luamplib}
\begin{mplibcode}
warningcheck := 0;
input hatching
beginfig(1)
pair p[];
picture Cee;
numeric i;
u = 1 / 2 * 1mm;
D := 300 * u;
B := 150 * u;
t := 5 * u;
L := 55 * u;
r := 13 * u;
p0 = (B/2 - r - t, D/2);
p1 = (-(B/2 - r - t), D/2);
p2 = (-B/2, D/2 - t - r);
p3 = (-B/2, -(D/2 - 2 * t - r));
p4 = (-(B/2 - r - t), -(D/2 - t));
p5 = (B/2 - r - 2 * t, -(D/2 - t));
p6 = (B/2 - t, -(D/2 - 2 * t - r));
p7 = (B/2 - t, -(D/2 - t - L));
p8 = (B/2 - 2 * t, -(D/2 - t - L));
p9 = (B/2 - 2 * t, -(D/2 - 2 * t - r));
p10 = (B/2 - 2 * t - r, -(D/2 - 2 * t));
p11 = (-(B/2 - r - t), -(D/2 - 2 * t));
p12 = (-(B/2 - t), -(D/2 - 2 * t - r));
p13 = (-(B/2 - t), D/2 - t - r);
p14 = (-(B/2 - t - r), D/2 - t);
p15 = (B/2 - r - t, D/2 - t);
Cee = image(
draw p0 -- p1;
draw quartercircle scaled 2(r+t) rotated (90) shifted (p1 - (0, r+t));
draw p2 -- p3;
draw quartercircle scaled 2(r+t) rotated (180) shifted (p3 + (r+t, 0));
draw p4 -- p5;
draw quartercircle scaled 2(r+t) rotated (270) shifted (p6 - (r+t, 0));
draw p6 -- p7 -- p8 -- p9;
draw quartercircle scaled 2r rotated (270) shifted (p10 + (0,r));
draw p10 -- p11;
draw quartercircle scaled 2r rotated (180) shifted (p11 + (0, r));
draw p12 -- p13;
draw quartercircle scaled 2r rotated (90) shifted (p13 + (r, 0));
draw p14 -- p15 -- p0;
);
draw Cee;
% hatchfill Cee withcolor (45, 2mm, -.5bp); % how can I build a cycle path for the picture??
for i = 0 upto 15:
label(decimal(i), p[i]);
endfor;
endfig;
\end{mplibcode}
\end{document}
答案1
您可以连接path
变量以及pair
中的变量path
。因此(经过一些简化)尝试以下操作:
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
beginfig(1);
input hatching
pair p[];
path Cee;
numeric B, D, L, t, r, u;
u = 1/2 mm;
D = 300 u;
B = 150 u;
t = 5 u;
L = 55 u;
r = 13 u;
p0 = (B/2 - r - t, D/2);
p1 = (-(B/2 - r - t), D/2);
p3 = (-B/2, -(D/2 - 2 * t - r));
p6 = (B/2 - t, -(D/2 - 2 * t - r));
p7 = (B/2 - t, -(D/2 - t - L));
p8 = (B/2 - 2 * t, -(D/2 - t - L));
p10 = (B/2 - 2 * t - r, -(D/2 - 2 * t));
p11 = (-(B/2 - r - t), -(D/2 - 2 * t));
p13 = (-(B/2 - t), D/2 - t - r);
p15 = (B/2 - r - t, D/2 - t);
Cee =
p0 --
quartercircle scaled 2(r+t) rotated 90 shifted (p1 - (0, r+t)) --
quartercircle scaled 2(r+t) rotated 180 shifted (p3 + (r+t, 0)) --
quartercircle scaled 2(r+t) rotated 270 shifted (p6 - (r+t, 0)) --
p7 -- p8 --
reverse quartercircle scaled 2r rotated 270 shifted (p10 + (0,r)) --
reverse quartercircle scaled 2r rotated 180 shifted (p11 + (0, r)) --
reverse quartercircle scaled 2r rotated 90 shifted (p13 + (r, 0)) --
p15 -- cycle;
draw Cee;
hatchfill Cee withcolor (45, 2mm, -.5bp);
endfig;
\end{mplibcode}
\end{document}
编译它以lualatex
获得显示以下内容的 PDF: