![如何创建营养标签正面图像?](https://linux22.com/image/383951/%E5%A6%82%E4%BD%95%E5%88%9B%E5%BB%BA%E8%90%A5%E5%85%BB%E6%A0%87%E7%AD%BE%E6%AD%A3%E9%9D%A2%E5%9B%BE%E5%83%8F%EF%BC%9F.png)
答案1
当你在等待 TikZ-maven 上钩时,这是我的努力元帖子。请点击链接获取有关 Metapost 的更多信息。您需要使用 编译此示例lualatex
。
缺少的“能量”标签留给读者作为练习。
\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\usepackage{fontspec}
\setmainfont{TeX Gyre Heros}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
vardef finger(expr agent, weight, type, rda) =
save P; picture P;
save S, C; path S, C;
save H; color H;
H = if type = "LOW" : 1/256(140, 195, 108)
elseif type = "MED" : 1/256(239, 179, 76)
elseif type = "HIGH": 1/256(223, 99, 58)
else: white fi;
save r; numeric r; r = 3/4;
C = fullcircle scaled 72;
S = subpath (2-r, 2+r) of C -- subpath (6-r, 6+r) of C -- cycle;
P = image(
fill S withcolor H;
draw S;
label(if abs(agent) > 6: "\small" & fi agent, 24 up);
label("\Large\textbf{" & weight & "}", 10 up);
fill superellipse(16 left, 6 up, 16 right, 6 down, .85) shifted 6 down withcolor white;
label(type, 6 down);
label("\large" & rda, 24 down);
draw (left--right) scaled 40 shifted 16 down
cutbefore subpath (2, 3) of S
cutafter subpath (5, 6) of S;
);
P
enddef;
label("Each serving (150g) contains", 44 up);
draw finger("Fat", "3.0g", "LOW", "4\%") shifted 40 left;
draw finger("Saturates", "1.3g", "LOW", "7\%");
draw finger("Sugar", "34g", "HIGH", "38\%") shifted 40 right;
draw finger("Salt", "0.9g", "MED", "15\%") shifted 80 right;
endfig;
\end{mplibcode}
\end{document}