环面到咖啡杯同伦

环面到咖啡杯同伦

有没有人有 TikZ 解决方案为咖啡杯制作动画 --> 甜甜圈同伦

在此处输入图片描述

答案1

直接取自如何画咖啡杯


那么,如果切开之后真的变成了甜甜圈(或多或少很平滑)呢?

代码

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{shadings}

\begin{document}

\foreach \x in {0,...,10}
{   \begin{tikzpicture}
        \shade[left color=gray!80, right color=gray!30] (-2,0-\x*0.04) -- (-2,-4+\x*0.04) arc (180:360:2 and 0.5) -- (2,0-\x*0.04) arc (360:180:2 and 0.5);
        \shade[left color=gray!60, right color=gray!20,even odd rule] (0,0-\x*0.04) circle (2 and 0.5) (0,0-\x*0.04) circle (1.8+\x*0.02 and 0.45+\x*0.005);
        \shade[left color=gray!30, right color=gray!80] (0,0-\x*0.04) circle (1.8+\x*0.02 and 0.45+\x*0.005);
        \begin{scope}
            \clip (2,-0.4) arc (90:270:0.05-\x*0.005 and 0.2) arc (90:-90:0.6 and 1.2) arc (90:270:0.05-\x*0.005 and 0.2) arc (-90:90:0.8 and 1.6);
            \fill[inner color=white, outer color=gray!60] (2,-2) circle (0.8 and 1.6);
        \end{scope}
        \draw (-2.1,-4.6) rectangle (2.9,0.6);
    \end{tikzpicture}
}

\foreach \x in {0,...,10}
{   \begin{tikzpicture}
        \shade[left color=gray!80, right color=gray!30] (-2+\x*0.36,-0.4) -- (-2+\x*0.36,-3.6) arc (180:360:2-\x*0.18 and 0.5-\x*0.05) -- (2,-0.4) arc (360:180:2-\x*0.18 and 0.5-\x*0.05);
        \shade[left color=gray!30, right color=gray!80] (0+\x*0.18,-0.4) circle (2-\x*0.18 and 0.5-\x*0.05);
        \begin{scope}
            \clip (2,-0.4) -- ++(0,-0.4) arc (90:-90:0.6 and 1.2) -- ++(0,-0.4) arc (-90:90:0.8 and 1.6);
            \fill[inner color=white, outer color=gray!60] (2,-2) circle (0.8 and 1.6);
        \end{scope}
        \draw (-2.1,-4.6) rectangle (2.9,0.6);
    \end{tikzpicture}
}

\foreach \x in {0,...,10}
{   \begin{tikzpicture}
        \begin{scope}
            \clip (2,-0.4) -- ++(-0.4+\x*0.04,0) arc (90:270:\x*0.08 and 1.6) -| ++(0.4-\x*0.04,0.4) arc (270:90:\x*0.06 and 1.2);
            \fill[inner color=white, outer color=gray!60] (1.2,-0.4) rectangle ++(1.6,-3.2);
        \end{scope}
        \begin{scope}
            \clip (2,-0.4) -- ++(0,-0.4) arc (90:-90:0.6 and 1.2) -- ++(0,-0.4) arc (-90:90:0.8 and 1.6);
            \fill[inner color=white, outer color=gray!60] (2,-2) circle (0.8 and 1.6);
        \end{scope}
        \draw (-2.1,-4.6) rectangle (2.9,0.6);
    \end{tikzpicture}
}

\foreach \x in {0,...,10}
{   \begin{tikzpicture}
        \fill[inner color=white, outer color=gray!60,even odd rule] (2-\x*0.16,-2) circle (0.8+\x*0.16 and 1.6) (2-\x*0.16,-2) circle (0.6+\x*0.09 and 1.2-\x*0.02);
        \draw (-2.1,-4.6) rectangle (2.9,0.6);
    \end{tikzpicture}
}

\end{document}

输出

在此处输入图片描述

相关内容