如何创建营养标签正面图像?

如何创建营养标签正面图像?

在此处输入图片描述

我想创建下面标签的乳胶图像,该标签正在成为英国食品包装的标准。这个标签的 TikZ 代码是什么样的?

答案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}

相关内容