编辑

编辑

我在 TikZ 中绘制了科赫雪花。我的代码如下。

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,intersections}
\usetikzlibrary{decorations.fractals}
\begin{document}
\begin{tikzpicture}[scale=2.2,decoration=Koch snowflake]
\draw[] decorate{decorate{decorate{decorate{decorate{ (-1.732,0) -- (0,3) -- (1.732, 0) -- (-1.732, 0)}}}}} ;
\end{tikzpicture}
\end{document}

我想知道是否可以制作类似雪花的动画动画曼德布洛。我尝试更改这篇文章中的代码,但这对我来说太难了。我可以在这方面寻求帮助吗?

答案1

\documentclass[border=9,tikz]{standalone}
\usetikzlibrary{arrows,intersections}
\usetikzlibrary{decorations.fractals}
\begin{document}
\def\n{10}
\foreach\i in{1,...,\n}{
    \tikz{
        \clip(-6,-.1)rectangle(6,3.5);
        \tikzset{shift={(0,3.4641016151)},scale={pow(3,\i/\n)},shift={(0,-3.4641016151)}}
        \draw[decoration=Koch snowflake,opacity=1-\i/\n]      {decorate{decorate{decorate{decorate{decorate{(-6,0)--(6,0)}}}}}};
        \draw[decoration=Koch snowflake,opacity=\i/\n]decorate{decorate{decorate{decorate{decorate{decorate{(-6,0)--(6,0)}}}}}};
    }
}
\end{document}

编辑

还有其他固定点,例如

\documentclass[border=9,tikz]{standalone}
\usetikzlibrary{arrows,intersections}
\usetikzlibrary{decorations.fractals}
\begin{document}
\def\n{20}
\foreach\i in{1,...,\n}{
    \tikz{
        \clip circle(4);
        \tikzset{scale={pow(3,\i/\n)},rotate=60*\i/\n}
        \draw[decoration=Koch snowflake]decorate{decorate{decorate{decorate{decorate{(-6.4285714,-1.2371791)--(3.5714286,-1.2371791)}}}}} ;
        \scoped[transparency group,opacity=\i/\n]\draw[decoration=Koch snowflake,fill=white]
                               decorate{decorate{decorate{decorate{decorate{decorate{(-6.4285714,-1.2371791)--(3.5714286,-1.2371791)}}}}}};
    }
}
\end{document}

无旋转

答案2

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{lindenmayersystems}

\tikzset{
  Koch curve/.style = {
    l-system={
      rule set={F -> F-F++F-F},
      axiom=F++F++F,
      step=1pt,
      angle=60,
      #1
    }
  }
}

\begin{document}

\foreach \order in {1,...,6,5,4,3,2} {
  \begin{tikzpicture}
    \draw[Koch curve={order=\order,step=500pt/3^(\order)}] l-system -- cycle;
  \end{tikzpicture}
}

\end{document}

在此处输入图片描述

答案3

你需要 http://tug.org/~hvoss/pst-koch2.styhttp://tug.org/~hvoss/pst-koch2.tex

\documentclass{article}
\usepackage{multido}
\usepackage{pst-koch2}
\pagestyle{empty}
\begin{document}

\multido{\iA=90+-1}{31}{%
\begin{pspicture}(-5.1,-5.1)(5.1,5.1)
  \psframe*(-5,-5)(5,5)
  \psKoch[N=4,base=squareB,motif=cesaro,angle=\iA,HSB=false,linestyle=none,fillstyle=solid,fillcolor=cyan,linecolor=red]
  \psKoch[N=4,base=squareB,motif=cesaro,angle=\iA]
\end{pspicture}\newpage}

\end{document}

在此处输入图片描述

还有一张更大的图片:http://tug.org/~hvoss/koch.gif

相关内容