# How to add solids in TikZ

I made this diagram in 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}


Which produces this image

How do I add black solids to the test tube above the flame of the bunsen burner? I want something like this:

Side note, this is similar to my previous question available here, but I decided to avoid the pslab package and just use tikz

Anyway, here is a TikZ proposal. Bonus: much easier to modify and much much lower compilation time, AND you could use @cfr's nice code for the flame ;-)

\documentclass[tikz,border=3.14mm,x11names,dvipsnames,svgnames]{standalone}
% from https://tex.stackexchange.com/a/372682/121799
}
\tikzset{%
\tikzset{%
#1
}
},
},
},
},
inner color/.style={
},
outer color/.style={
},
mid color/.style={
},
}
\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);
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}


For Sebastiano: moving flame and some Brownian motion ;-)

\documentclass[tikz,border=3.14mm,x11names,dvipsnames,svgnames]{standalone}
% from https://tex.stackexchange.com/a/372682/121799
}
\tikzset{%
\tikzset{%
#1
}
},
},
},
},
inner color/.style={
},
outer color/.style={
},
mid color/.style={
},
}
\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);
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}


• But if the flame moves, the figure is even more beautiful. :-) – Sebastiano Jul 19 '18 at 7:30
• @Sebastiano You're right. I updated. ;-) – marmot Jul 19 '18 at 7:40
• ahahahah. Excellent very very execellent. – Sebastiano Jul 19 '18 at 7:42
• +1 Love the Brownian motion! – Andrew Jul 19 '18 at 8:02
• Damn, already upvoted before your edit. Vote to make it possible to upvote edits separately. – Max Jul 19 '18 at 8:10

Nice drawing! Perhaps something like this:

I have only added three "solids" but this should be OK for proof-of-concept. For good measure I have also tilted the test tube and put the flame over the top.

Here's the modified code:

\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} {
}
\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}


Edit

Marmot inspired random solids:

\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 (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}