\r=1.95(错误的)

\r=1.95(错误的)

为什么当我将半径\r从 1.9 增加到 1.95 时会出现跳帧?

\documentclass[tikz]{standalone}
\begin{document}
\pgfmathsetmacro{\r}{1.95}
\foreach \j in {0,10,20,...,110}{%
\begin{tikzpicture}%
 \draw (-2.2,-2.2) rectangle (2.2,2.2);%
 \draw(0,0) circle (.25);%
 \foreach \i in {0,1,2}{\draw[rotate=\i*120] (\j:\r) arc (\j:90+\j:\r) -- (90+\j:.3) arc (90+\j:\j:.3) -- cycle;}%
\end{tikzpicture}}%
\end{document}

\r=1.95(错误的)

在此处输入图片描述

\r=1.9(正确的)

在此处输入图片描述

答案1

确保您知道如何使用\pgfresetboundingbox\pgfinterruptboundingbox

播放代码

这基本上就是手册中的例子show path construction。除了曲线之外,我还展示了支撑点,因此可以看出支撑点超出了框架。

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\pgfmathsetmacro{\r}{2.1}
\tikzset{
    decoration={
        show path construction,
        moveto code={
            \fill[red](\tikzinputsegmentfirst)circle(2pt)
                node[fill=none,below]{moveto};},
        lineto code={
            \draw[blue,->](\tikzinputsegmentfirst)--(\tikzinputsegmentlast)
                node[pos=.5,auto]{lineto};
        },
        curveto code={
            \draw[green!75!black,dashed](\tikzinputsegmentfirst)--(\tikzinputsegmentsupporta)
                (\tikzinputsegmentlast)--(\tikzinputsegmentsupportb);
            \draw[green!75!black,->](\tikzinputsegmentfirst)..controls
                (\tikzinputsegmentsupporta)and(\tikzinputsegmentsupportb)
                ..(\tikzinputsegmentlast)node[pos=.5,auto]{curveto};
        },
        closepath code={
            \draw[orange,->](\tikzinputsegmentfirst)--(\tikzinputsegmentlast)
                node[pos=.5,auto]{closepath};
        }
    }
}
\foreach \j in {0,5,...,119}{
    \tikz[scale=3]{
        \draw[line width=1.2](-2.2,-2.2)rectangle(2.2,2.2)(0,0)circle(.25);
        \foreach\i in{0,1,2}{
            \draw[rotate=\i*120,decorate](\j:\r)arc(\j:90+\j:\r)--(90+\j:.3)arc(90+\j:\j:.3)--cycle;
        }% 
    }
}%
\end{document}

也可以看看

答案2

使用半径为 \r (加上一些值)的圆来计算边界框。

\useasboundingbox覆盖自动 BBox 计算,其中包括不可见路径组件,例如曲线的控制点。

\documentclass[tikz]{standalone}
\begin{document}
\pgfmathsetmacro{\r}{1.95}
\foreach \j in {0,10,20,...,110}{%
\begin{tikzpicture}%
% \draw (-2.2,-2.2) rectangle (2.2,2.2);%
  \useasboundingbox (0,0) circle (\r+0.01);                   
 \draw(0,0) circle (.25);%
 \foreach \i in {0,1,2}{\draw[rotate=\i*120] (\j:\r) arc (\j:90+\j:\r) -- (90+\j:.3) arc (90+\j:\j:.3) -- cycle;}%
\end{tikzpicture}}%
\end{document}

相关内容