如何调整 tikzfoldingdodecahedron 面的背景颜色?

如何调整 tikzfoldingdodecahedron 面的背景颜色?

tikzfoldingdodecahedron以日历为例示例。这是我的 MWE:

\documentclass{article}
% Folding + calendar example from the PGF manual.

\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usetikzlibrary{calendar,folding}
\begin{document}
\sffamily\scriptsize
\begin{tikzpicture}
 [transform shape, every calendar/.style={at={(-8ex,4ex)},
 week list,
 month label above centered,
 month text=\bfseries\textcolor{red}{\%mt} \%y0,
 if={(Sunday) [black!50]}
 }]
 \tikzfoldingdodecahedron
 [
 folding line length=2.5cm,
     face 1={ \calendar [dates=\the\year-01-01 to \the\year-01-last];},
     face 2={ \calendar [dates=\the\year-02-01 to \the\year-02-last];},
     face 3={ \calendar [dates=\the\year-03-01 to \the\year-03-last];},
     face 4={ \calendar [dates=\the\year-04-01 to \the\year-04-last];},
     face 5={ \calendar [dates=\the\year-05-01 to \the\year-05-last];},
     face 6={ \calendar [dates=\the\year-06-01 to \the\year-06-last];},
     face 7={ \calendar [dates=\the\year-07-01 to \the\year-07-last];},
     face 8={ \calendar [dates=\the\year-08-01 to \the\year-08-last];},
     face 9={ \calendar [dates=\the\year-09-01 to \the\year-09-last];},
     face 10={\calendar [dates=\the\year-10-01 to \the\year-10-last];},
     face 11={\calendar [dates=\the\year-11-01 to \the\year-11-last];},
     face 12={\calendar [dates=\the\year-12-01 to \the\year-12-last];}
 ];
 \end{tikzpicture}
 \end{document}

我想根据自己的选择更改特定月份的背景颜色。我尝试修改相关部分,如下所示:

\tikzfoldingdodecahedron[
    folding line length=2.5cm, fold/.style=dotted, every face/.fill=green
    face 1={\node(name)[] ...

然而,它只填补了第一面白色的且不符合规定绿色的(见下文)。

非绿色日历界面截图

我还检查了tikz 和 pgf 手册位于第 660/661 页,但对于本案没有帮助。

因此从本质上来说,我的问题是:

我们如何修改原始示例以拥有个性化选择的彩色背景颜色?有人有什么办法可以让我的生活再次丰富多彩吗?

答案1

面并没有真正构造出来:内容只是以面为中心,每个边缘都是单独绘制的。这使得用特定颜色填充面变得困难。我有一个稍微修改过的版本,可以用特定颜色填充所有面,或者用特定颜色填充所有给定大小的面。但是,如果我理解正确的话,你想要给特定的面上色。在这种情况下,我认为最好的解决方案是明确地将面绘制为其内容。

为了使这更容易,您可以使用此命令,以当前位置为中心绘制具有指定边长的五边形。

\newlength{\fll} %folding line length
\setlength{\fll}{2.5cm}
\newcommand{\colouredpentagon}[1]{\path[fill=#1] (-.5\fll,-0.68819\fll) --
++(\fll,0) -- ++(72:\fll) -- ++(144:\fll) -- ++(-144:\fll) -- 
(-.5\fll,-0.68819\fll) -- cycle;}

这也许可以用更好的方式来实现,但作为一个快速的解决方案它就足够了。

下面是重复日历代码的示例,但现在为两个面着色。

\documentclass{standalone}
% Folding + calendar example from the PGF manual.

\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usetikzlibrary{calendar,folding}
\begin{document}
\sffamily\scriptsize
\newlength{\fll} %folding line length
\setlength{\fll}{2.5cm}
\newcommand{\colouredpentagon}[1]{\path[fill=#1] (-.5\fll,-0.68819\fll) -- ++(\fll,0) -- ++(72:\fll) -- ++(144:\fll) -- ++(-144:\fll) -- (-.5\fll,-0.68819\fll) -- cycle;}
\begin{tikzpicture}
 [transform shape, every calendar/.style={at={(-8ex,4ex)},
 week list,
 month label above centered,
 month text=\bfseries\textcolor{red}{\%mt} \%y0,
 if={(Sunday) [black!50]}
 }]
 \tikzfoldingdodecahedron
 [
 folding line length=2.5cm,
     face 1={ \calendar [dates=\the\year-01-01 to \the\year-01-last];},
     face 2={ \calendar [dates=\the\year-02-01 to \the\year-02-last];},
     face 3={ \calendar [dates=\the\year-03-01 to \the\year-03-last];},
     face 4={ \colouredpentagon{yellow} \calendar [dates=\the\year-04-01 to \the\year-04-last];},
     face 5={ \calendar [dates=\the\year-05-01 to \the\year-05-last];},
     face 6={ \calendar [dates=\the\year-06-01 to \the\year-06-last];},
     face 7={ \calendar [dates=\the\year-07-01 to \the\year-07-last];},
     face 8={ \calendar [dates=\the\year-08-01 to \the\year-08-last];},
     face 9={ \calendar [dates=\the\year-09-01 to \the\year-09-last];},
     face 10={\colouredpentagon{pink} \calendar [dates=\the\year-10-01 to \the\year-10-last];},
     face 11={\calendar [dates=\the\year-11-01 to \the\year-11-last];},
     face 12={\calendar [dates=\the\year-12-01 to \the\year-12-last];}
 ];
 \end{tikzpicture}
 \end{document}

这应产生以下日历: 双色日历

相关内容