如何在 TikZ 中添加固体

如何在 TikZ 中添加固体

我在 tikz 中制作了这个图表

\begin{tikzpicture}[xscale=0.4,yscale=0.4]
\draw (0,4) -- (10,4); 
\draw (0,6) -- (10,6); 
\draw (8,4.75) -- (19.75,4.75) -- (19.75,-5.25); 
\draw (8,5.25) -- (20.25,5.25) -- (20.25,-5.25); 
\draw (0,4) .. controls (-1.3,4) and (-1.3,6) .. (0,6); 
\fill[black!20] (9,4.75) -- (12,4.75) -- (12,3.6) -- (9,4.25) -- (9,4.75); 
\fill[black!20] (9,5.25) -- (12,5.25) -- (12,6.4) -- (9,5.75) -- (9,5.25); 
\draw (21,3) -- (21,-7); 
\draw (19,3) -- (19,-7); 
\draw (19,-7) .. controls (19,-8.3) and (21,-8.3) .. (21,-7); 
\draw (19,0) -- (19.75,0); 
\draw (20.25,0) -- (21,0); 
\draw (-6,-18) rectangle (8,-17.5); 
\draw (-6,-17.5) -- (0.3, -16); 
\draw (0.3,-16) rectangle (1.7,-14); \draw (1,-15) circle (0.5); 
\draw (8,-17.5) -- (1.7,-16); 
\draw (0.5,-14) rectangle (1.5,0); 
\draw (0.5,0) .. controls (-1,0.5) and (1.1,2) .. (1,3); 
\draw (1.5,0) .. controls (3,0.5) and (0.9,2) .. (1,3); 
\end{tikzpicture}

生成此图像 在此处输入图片描述

如何将黑色固体添加到本生灯火焰上方的试管中?我想要这样的东西:

在此处输入图片描述

附注:这和我之前的问题类似可在此处获得,但我决定避免使用 pslab 包,而只使用 tikz

答案1

无论如何,这是一个 TiZ 提案。优点:修改起来更容易,编译时间也短得多,你可以使用@cfr 的火焰代码很棒;-)

\documentclass[tikz,border=3.14mm,x11names,dvipsnames,svgnames]{standalone}
% from https://tex.stackexchange.com/a/372682/121799
\pgfdeclareradialshading[fradialcolour1,fradialcolour2,fradialcolour3]{fncyradial}{\pgfpoint{0}{0}}{% manual 1082-1083; later - shading is assumed to be 100bp diameter ??
  color(0)=(fradialcolour1);
  color(20bp)=(fradialcolour2);
  color(40bp)=(fradialcolour3);
  color(50bp)=(fradialcolour3)
}
\tikzset{%
  fradial/.code={%
        \tikzset{%
          fancy radial/.cd,
          shading=fncyradial,
          #1
        }
  },
  fancy radial/.search also={/tikz},
  fancy radial/.cd,
  fancy radial inner colour/.code={
        \colorlet{fradialcolour1}{#1}
  },
  fancy radial mid colour/.code={
        \colorlet{fradialcolour2}{#1}
  },
  fancy radial outer colour/.code={
        \colorlet{fradialcolour3}{#1}
  },
  fancy radial inner colour=black,
  fancy radial outer colour=black,
  fancy radial mid colour=white,
  inner color/.style={
        fancy radial inner colour=#1,
  },
  outer color/.style={
        fancy radial outer colour=#1,
  },
  mid color/.style={
        fancy radial mid colour=#1,
  },
}
\begin{document}
\begin{tikzpicture}[xscale=0.4,yscale=0.4]
\draw (0,4) -- (10,4); 
\draw (0,6) -- (10,6); 
\draw (8,4.75) -- (19.75,4.75) -- (19.75,-5.25); 
\draw (8,5.25) -- (20.25,5.25) -- (20.25,-5.25); 
\draw (0,4) .. controls (-1.3,4) and (-1.3,6) .. (0,6); 
\fill[black!20] (9,4.75) -- (12,4.75) -- (12,3.6) -- (9,4.25) -- (9,4.75); 
\fill[black!20] (9,5.25) -- (12,5.25) -- (12,6.4) -- (9,5.75) -- (9,5.25); 
\draw (21,3) -- (21,-7); 
\draw (19,3) -- (19,-7); 
\draw (19,-7) .. controls (19,-8.3) and (21,-8.3) .. (21,-7); 
\draw (19,0) -- (19.75,0); 
\draw (20.25,0) -- (21,0); 
\draw (-6,-18) rectangle (8,-17.5); 
\draw (-6,-17.5) -- (0.3, -16); 
\draw (0.3,-16) rectangle (1.7,-14); \draw (1,-15) circle (0.5); 
\draw (8,-17.5) -- (1.7,-16); 
\draw (0.5,-14) rectangle (1.5,0); 
\shade[fradial={inner color=Gold1, outer color=OrangeRed, 
mid color=BurntOrange}] (0.5,0) .. controls (-1,0.5) and (1.1,2) .. (1,3)
.. controls (0.9,2) and  (3,0.5) .. (1.5,0) -- cycle; 
%\draw (1.5,0) .. controls (3,0.5) and (0.9,2) .. (1,3); 
\foreach \X in {1,...,99}
{\fill (1.25+rand,{4.07+abs(rand*rand*rand*rand*rand*rand)}) circle (2pt);}
\end{tikzpicture}
\end{document}

在此处输入图片描述

对于塞巴斯蒂亚诺来说:移动的火焰和一些布朗运动;-)

\documentclass[tikz,border=3.14mm,x11names,dvipsnames,svgnames]{standalone}
% from https://tex.stackexchange.com/a/372682/121799
\pgfdeclareradialshading[fradialcolour1,fradialcolour2,fradialcolour3]{fncyradial}{\pgfpoint{0}{0}}{% manual 1082-1083; later - shading is assumed to be 100bp diameter ??
  color(0)=(fradialcolour1);
  color(20bp)=(fradialcolour2);
  color(40bp)=(fradialcolour3);
  color(50bp)=(fradialcolour3)
}
\tikzset{%
  fradial/.code={%
        \tikzset{%
          fancy radial/.cd,
          shading=fncyradial,
          #1
        }
  },
  fancy radial/.search also={/tikz},
  fancy radial/.cd,
  fancy radial inner colour/.code={
        \colorlet{fradialcolour1}{#1}
  },
  fancy radial mid colour/.code={
        \colorlet{fradialcolour2}{#1}
  },
  fancy radial outer colour/.code={
        \colorlet{fradialcolour3}{#1}
  },
  fancy radial inner colour=black,
  fancy radial outer colour=black,
  fancy radial mid colour=white,
  inner color/.style={
        fancy radial inner colour=#1,
  },
  outer color/.style={
        fancy radial outer colour=#1,
  },
  mid color/.style={
        fancy radial mid colour=#1,
  },
}
\begin{document}
\foreach \X in {0,10,...,350}
{\begin{tikzpicture}[xscale=0.4,yscale=0.4]
\draw (0,4) -- (10,4); 
\draw (0,6) -- (10,6); 
\draw (8,4.75) -- (19.75,4.75) -- (19.75,-5.25); 
\draw (8,5.25) -- (20.25,5.25) -- (20.25,-5.25); 
\draw (0,4) .. controls (-1.3,4) and (-1.3,6) .. (0,6); 
\fill[black!20] (9,4.75) -- (12,4.75) -- (12,3.6) -- (9,4.25) -- (9,4.75); 
\fill[black!20] (9,5.25) -- (12,5.25) -- (12,6.4) -- (9,5.75) -- (9,5.25); 
\draw (21,3) -- (21,-7); 
\draw (19,3) -- (19,-7); 
\draw (19,-7) .. controls (19,-8.3) and (21,-8.3) .. (21,-7); 
\draw (19,0) -- (19.75,0); 
\draw (20.25,0) -- (21,0); 
\draw (-6,-18) rectangle (8,-17.5); 
\draw (-6,-17.5) -- (0.3, -16); 
\draw (0.3,-16) rectangle (1.7,-14); \draw (1,-15) circle (0.5); 
\draw (8,-17.5) -- (1.7,-16); 
\draw (0.5,-14) rectangle (1.5,0); 
\shade[fradial={inner color=Gold1, outer color=OrangeRed, 
mid color=BurntOrange}] (0.5,0) .. controls ({-1+0.2*sin(\X+60*rand)},{0.5+0.2*cos(\X+60*rand)}) and 
({1.1+0.2*sin(\X+60*rand)},{2+0.2*cos(\X+60*rand)}) .. (1,{3+0.2*cos(\X+60*rand)})
.. controls ({0.9+0.2*sin(\X+60*rand)},{2+0.2*cos(\X+60*rand)}) and  ({3+0.2*sin(\X+60*rand)},{0.5+0.2*cos(\X+60*rand)}) .. (1.5,0) -- cycle; 
%\draw (1.5,0) .. controls (3,0.5) and (0.9,2) .. (1,3); 
\foreach \X in {1,...,99}
{\fill (1.25+rand,{4.07+abs(rand*rand*rand*rand*rand*rand)}) circle (2pt);}
\end{tikzpicture}}
\end{document}

在此处输入图片描述

答案2

画得真好!也许是这样的:

在此处输入图片描述

我只添加了三个“固体”,但这对于概念验证来说应该没问题。为了保险起见,我还倾斜了试管,并将火焰放在顶部。

修改后的代码如下:

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[xscale=0.4,yscale=0.4]
  \begin{scope}[rotate=30,xshift=18mm,yshift=-34mm]
    \draw (0,4) -- (10,4);
    \draw (0,6) -- (10,6);
    \draw (8,4.75) -- (19.75,4.75) -- (19.75,-5.25);
    \draw (8,5.25) -- (20.25,5.25) -- (20.25,-5.25);
    \foreach \pt/\r in {(1,5)/2, (0.5,4.5)/1.5, (-0.5,5)/2.6} {
       \filldraw[black] \pt circle [radius=\r mm];
    }
    \draw (0,4) .. controls (-1.3,4) and (-1.3,6) .. (0,6);
    \fill[black!20] (9,4.75) -- (12,4.75) -- (12,3.6) -- (9,4.25) -- (9,4.75);
    \fill[black!20] (9,5.25) -- (12,5.25) -- (12,6.4) -- (9,5.75) -- (9,5.25);
    \draw (21,3) -- (21,-7);
    \draw (19,3) -- (19,-7);
    \draw (19,-7) .. controls (19,-8.3) and (21,-8.3) .. (21,-7);
    \draw (19,0) -- (19.75,0);
    \draw (20.25,0) -- (21,0);
  \end{scope}
  \draw (-6,-18) rectangle (8,-17.5);
  \draw (-6,-17.5) -- (0.3, -16);
  \draw (0.3,-16) rectangle (1.7,-14); \draw (1,-15) circle (0.5);
  \draw (8,-17.5) -- (1.7,-16);
  \draw (0.5,-14) rectangle (1.5,0);
  \draw[fill=white] (0.5,0) .. controls (-1,0.5) and (1.1,2) .. (1,3)
                            .. controls (0.9,2) and (3,0.5)  .. (1.5,0);
\end{tikzpicture}

\end{document}

编辑

受土拨鼠启发的随机固体:

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[scale=0.3]
  \begin{scope}[rotate=30,xshift=18mm,yshift=-34mm]
    \draw (0,4) -- (10,4);
    \draw (0,6) -- (10,6);
    \draw (8,4.75) -- (19.75,4.75) -- (19.75,-5.25);
    \draw (8,5.25) -- (20.25,5.25) -- (20.25,-5.25);
    \foreach \pt in {1,...,40} {
       \pgfmathparse{(2*rnd)}
       \draw[fill=black] (rand+0.4,5+0.8*rand) circle [radius=1.2mm];
    }
    \draw (0,4) .. controls (-1.3,4) and (-1.3,6) .. (0,6);
    \fill[black!20] (9,4.75) -- (12,4.75) -- (12,3.6) -- (9,4.25) -- (9,4.75);
    \fill[black!20] (9,5.25) -- (12,5.25) -- (12,6.4) -- (9,5.75) -- (9,5.25);
    \draw (21,3) -- (21,-7);
    \draw (19,3) -- (19,-7);
    \draw (19,-7) .. controls (19,-8.3) and (21,-8.3) .. (21,-7);
    \draw (19,0) -- (19.75,0);
    \draw (20.25,0) -- (21,0);
  \end{scope}
  \draw (-6,-18) rectangle (8,-17.5);
  \draw (-6,-17.5) -- (0.3, -16);
  \draw (0.3,-16) rectangle (1.7,-14); \draw (1,-15) circle (0.5);
  \draw (8,-17.5) -- (1.7,-16);
  \draw (0.5,-14) rectangle (1.5,0);
  \draw[fill=white] (0.5,0) .. controls (-1,0.5) and (1.1,2) .. (1,3)
                            ..  controls (0.9,2) and (3,0.5)  .. (1.5,0);
\end{tikzpicture}

\end{document}

相关内容