带有变换画布的 TikZ 图片不起作用(有错误?)

带有变换画布的 TikZ 图片不起作用(有错误?)

我正在为我工​​作的实验室制作一个 beamer 模板。由于我找不到徽标的 SVG 或 PDF 版本,我决定使用 tikz 绘制它(我在原始 PNG 上绘制,这就是为什么代码非常固定的原因)。我认为让模板定义带有pic徽标以供将来使用可能是一个好主意,所以我尝试将图片代码复制/粘贴到,pic但即使我使用了显式边界框,使用的部分transform canvas也没有被绘制...

平均能量损失

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\tikzset{%
pics/polo/.style={%
    code={%
    \useasboundingbox (-108.12047pt,-54.0623pt) rectangle (108.12047pt,54.0623pt);
    \begin{scope}[even odd rule,xslant=0.6]
    \fill (-1.5mm-81.65935pt,11mm-45.16873pt) coordinate (P) -- ++(20pt,0) -- ++(0,13pt) coordinate (tmp) -- ++(20pt,0) to[out=5,in=0, looseness=2.6] ++(0,20pt) -| cycle
    (tmp) ++(1pt,6pt) -- ++(6pt,0) to[out=5,in=0, looseness=4] ++(1pt,7.75pt) -| cycle;
    \fill[looseness=3.4] (P) ++(29.5mm,0) coordinate (Po) to[out=3, in=0] ++(-2pt,22pt) to[out=185, in=180] cycle [looseness=2.5] (Po) ++(-.5pt,5pt) to[out=3, in=0] ++(0pt,12pt) to[out=185, in=180] cycle;
    \fill (P) ++(39.25mm,0) coordinate (Pol) -- ++(32pt,0) -- ++(0,6pt) -- ++(-19pt,0) -- ++(0pt,15pt) -| cycle;
    \fill[looseness=3.4] (P) ++(59.5mm,0mm) coordinate (Polo) to[out=3, in=0] ++(-2pt,22pt) to[out=185, in=180] cycle [looseness=2.5]  (Polo) ++(-.5pt,5pt) to[out=3, in=0] ++(0pt,12pt) to[out=185, in=180] cycle;
    \end{scope}
    \fill (P) ++(-4.5mm,9mm) coordinate (vertex) to[out=50, in=180, looseness=0.75] ++(38mm,10.75mm) coordinate (top) -- ++(-115:11.5pt) to[out=180, in=30, looseness=0.95] cycle;
    \fill[#1] (top) ++(4pt,0) coordinate (a) ++(-115:11.5pt) coordinate (b) (a) to[out=0,in=175] ++(27pt,-1.5pt) -- ++(-115:11.5pt) to[out=175, in=0] (b) -- cycle;
    \path (vertex) -- coordinate (rot) ++(75.25mm,11.75mm-20mm);
    \begin{scope}[transform canvas={rotate around={-180:(rot)}}]
    \fill (P) ++(-4.5mm,9mm) to[out=50, in=180, looseness=0.75] ++(38mm,10.75mm) coordinate (tmp) -- ++(-115:11.5pt) to[out=180, in=30, looseness=0.95] cycle;
    \fill[#1] (tmp) ++(4pt,0) coordinate (a) ++(-115:11.5pt) coordinate (b) (a) to[out=0,in=175] ++(27pt,-1.5pt) -- ++(-115:11.5pt) to[out=175, in=0] (b) -- cycle;
    \end{scope}
    }}}

\begin{document}
\begin{tikzpicture}

\pic[blue]{polo=orange};

\begin{scope}[yshift=4cm,blue]
    \useasboundingbox (-108.12047pt,-54.0623pt) rectangle (108.12047pt,54.0623pt);
    \begin{scope}[even odd rule,xslant=0.6]
    \fill (-1.5mm-81.65935pt,11mm-45.16873pt) coordinate (P) -- ++(20pt,0) -- ++(0,13pt) coordinate (tmp) -- ++(20pt,0) to[out=5,in=0, looseness=2.6] ++(0,20pt) -| cycle
    (tmp) ++(1pt,6pt) -- ++(6pt,0) to[out=5,in=0, looseness=4] ++(1pt,7.75pt) -| cycle;
    \fill[looseness=3.4] (P) ++(29.5mm,0) coordinate (Po) to[out=3, in=0] ++(-2pt,22pt) to[out=185, in=180] cycle [looseness=2.5] (Po) ++(-.5pt,5pt) to[out=3, in=0] ++(0pt,12pt) to[out=185, in=180] cycle;
    \fill (P) ++(39.25mm,0) coordinate (Pol) -- ++(32pt,0) -- ++(0,6pt) -- ++(-19pt,0) -- ++(0pt,15pt) -| cycle;
    \fill[looseness=3.4] (P) ++(59.5mm,0mm) coordinate (Polo) to[out=3, in=0] ++(-2pt,22pt) to[out=185, in=180] cycle [looseness=2.5]  (Polo) ++(-.5pt,5pt) to[out=3, in=0] ++(0pt,12pt) to[out=185, in=180] cycle;
    \end{scope}
    \fill (P) ++(-4.5mm,9mm) coordinate (vertex) to[out=50, in=180, looseness=0.75] ++(38mm,10.75mm) coordinate (top) -- ++(-115:11.5pt) to[out=180, in=30, looseness=0.95] cycle;
    \fill[orange] (top) ++(4pt,0) coordinate (a) ++(-115:11.5pt) coordinate (b) (a) to[out=0,in=175] ++(27pt,-1.5pt) -- ++(-115:11.5pt) to[out=175, in=0] (b) -- cycle;
    \path (vertex) -- coordinate (rot) ++(75.25mm,11.75mm-20mm);
    \begin{scope}[transform canvas={rotate around={-180:(rot)}}]
    \fill (P) ++(-4.5mm,9mm) to[out=50, in=180, looseness=0.75] ++(38mm,10.75mm) coordinate (tmp) -- ++(-115:11.5pt) to[out=180, in=30, looseness=0.95] cycle;
    \fill[orange] (tmp) ++(4pt,0) coordinate (a) ++(-115:11.5pt) coordinate (b) (a) to[out=0,in=175] ++(27pt,-1.5pt) -- ++(-115:11.5pt) to[out=175, in=0] (b) -- cycle;
    \end{scope}
\end{scope}
\end{tikzpicture}
\end{document}

第一个徽标pic code直接使用,第二个徽标使用\pic命令。可以看出,徽标的底部缺失,但边界框实际上在那里。

在此处输入图片描述

答案1

这不是一个错误。正如.percusse 注释的,变换画布选项直接发送到驱动程序,因此边界框限制被覆盖。

所使用的解决方案只是重新构建图纸,以便适应这些限制(解决方案在问题评论中)。

相关内容