我想在现有的基础上添加一束类似图片中的火焰
我目前有这个:
\begin{tikzpicture}
\draw (-4,-1.5) rectangle (1.5,1.5);
\draw (-4.5,0.5) -- (-1,0.5);
\draw (-0.5,1) .. controls (-1,1) and (-1,1) .. (-1,0.5) .. controls (-1,0) and (-1,0) .. (-0.5,0);
\draw (-4.5,-0.5) -- (-1,-0.5);
\draw[densely dashed] (1.5,0) -- (8.5,0);
\draw (3.5,-0.5) .. controls (3.5,-1.5) and (4,-1.5) .. (4.5,-1.5);
\draw (3.5,-0.5) node (v1) {} -- (6.5,-0.5);
\draw (5.5,-1.5) .. controls (6,-1.5) and (6.5,-1.5) .. (6.5,-0.5);
\draw (4.5,-1.5) -- (4.5,-3.5);
\draw (5.5,-1.5) -- (5.5,-3.5);
\draw (5,-2.5) -- (5,-6);
\draw (4,-4.5) -- (4,-5.5) .. controls (4,-6.5) and (4,-6.5) .. (4.5,-6.5) .. controls (5,-6.5) and (5,-6.5) .. (5.5,-6.5) .. controls (6,-6.5) and (6,-6.5) .. (6,-5.5) -- (6,-4.5);
\draw (4,-5.5) -- (6,-5.5);
\draw (8,-1) -- (9,1) -- (10,-1) -- (8,-1);
\begin{scope}[yshift=5cm,rotate=-30]
\draw (13,0.5) rectangle (13.5,2);
\node(fail) at (13,1.25) {};
\draw (13,-2) rectangle (13.5,-0.5);
\draw (14.5,-1) rectangle (16.5,1);
\node[above,rotate=-30] at (15.5,1) {Detector};
\draw (17,-0.5) rectangle (18.5,0.5);
\node[above,rotate=-30] at (17.75,0.5) {Recorder};
\node(detector) at (14.5,0) {};
\draw (16.5,0) -- (17,0);
\node[above,rotate=-30] at (13.25,2) {Slit};
\end{scope}
\draw[densely dashed] (9.5,0) -- (fail);
\draw[densely dashed] (9.5,0) -- (detector);
\node[anchor=north,align=center] at (-1.25,-1.5) {Lamp emits wavelengths of required\\energy to excite electron. The cathode\\of the lamp is the metal to be analysed};
\node[anchor=east,align=right] at (4,-6) {Analyte sample\\in beaker};
\draw (5,-4) -- (4,-4) node[left] {Capillary tube};
\node[align=center] at (9,-2) {monochromator\\and slit select\\light of particular\\wavelength};
\draw[-latex] (4,-2) node[left] {fuel} -- (4.5,-2);
\draw[-latex] (4,-2.5) node[left] {air} -- (4.5,-2.5);
\node at (2.5,0.5) {$P_{0}$};
\node at (7.5,0.5) {$P$};
% Flame goes here:
\shadedraw[bottom color=white,top color=cyan!50!blue] (v1) rectangle (6.5,1.5);
% Terrible Flame:
\shadedraw[bottom color=blue!60!cyan,top color=white] (3.5,-0.5) -- (3.5,1) -- (4,0) -- (4.5,0.5) -- (5,0) -- (5.5,1) -- (6,0) -- (6.5,0.5) -- (6.5,-0.5) -- (3.5,-0.5);
\end{tikzpicture}
有没有什么简单的方法或捷径可以产生那种火焰?请注意,我并不是在模仿图像的其余部分,我只是想重现火焰
使用 Marmot/Jake 的代码的火焰
可以通过将相关部分更改为以下内容来重现:
\shadedraw[bottom color=blue!60!cyan,top color=white,mysine=20pt]
(3.5,-0.5) -- (3.5,0) decorate {(3.5,0) -- (3.7,0.9) -- (3.8,0.1) -- (4,0)}
..controls +(-100:0.3) and +(-80:0.1).. (4,0) [mysine=15pt] decorate {(4,0) -- (4,0.9) -- (4.2,0)}
.. controls +(-70:0.3) and +(-90:0.4) .. (4.5,0) [mysine=25pt] decorate {(4.5,0) -- (4.6,1) -- (4.8,0)}
.. controls +(-70:0.2) and +(-80:0.2).. (5,0)[mysine=18pt] decorate {(5,0) -- (5.1,0.9) -- (5.3,0)}
.. controls +(-70:0.1) and +(180:0.1) .. +(0.1,-0.2) .. controls +(0:0.1) and +(-90:0.1) .. (5.5,0) decorate {(5.5,0) -- (5.6,0.9) -- (5.8,0)}
.. controls +(-70:0.1) and +(-85:0.3) .. (6,0) decorate[mysine=22pt] {(6,0) -- (6.1,0.9) -- (6.3,0)}
.. controls +(-70:0.2) and +(90:0.1) .. (6.5,0) -- (6.5,-0.5) --
(3.5,-0.5) -- (3.5,0);
答案1
这使用杰克的完整正弦以及 Mark Wibrow 在评论中教给我的一些技巧:可以decorate
在路径中使用,请参阅下面的应用程序。我相信 Mark 可以做得更好。我还缩进了你的代码,因为现在我因为不这样做而被否决了。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations}
% https://tex.stackexchange.com/a/25689/121799
\pgfdeclaredecoration{complete sines}{initial}
{
\state{initial}[
width=+0pt,
next state=sine,
persistent precomputation={\pgfmathsetmacro\matchinglength{
\pgfdecoratedinputsegmentlength / int(\pgfdecoratedinputsegmentlength/\pgfdecorationsegmentlength)}
\setlength{\pgfdecorationsegmentlength}{\matchinglength pt}
}] {}
\state{sine}[width=\pgfdecorationsegmentlength]{
\pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
\pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
\pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
\pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
}
\state{final}{}
}
\begin{document}
\begin{tikzpicture}[mysine/.style={decoration={complete sines,segment
length=#1,amplitude=1.23pt,path has corners}},mysine/.default=9.5pt]
\draw (-4,-1.5) rectangle (1.5,1.5);
\draw (-4.5,0.5) -- (-1,0.5);
\draw (-0.5,1) .. controls (-1,1) and (-1,1) .. (-1,0.5) .. controls (-1,0) and (-1,0) .. (-0.5,0);
\draw (-4.5,-0.5) -- (-1,-0.5);
\draw[densely dashed] (1.5,0) -- (8.5,0);
\draw (3.5,-0.5) .. controls (3.5,-1.5) and (4,-1.5) .. (4.5,-1.5);
\draw (3.5,-0.5) node (v1) {} -- (6.5,-0.5);
\draw (5.5,-1.5) .. controls (6,-1.5) and (6.5,-1.5) .. (6.5,-0.5);
\draw (4.5,-1.5) -- (4.5,-3.5);
\draw (5.5,-1.5) -- (5.5,-3.5);
\draw (5,-2.5) -- (5,-6);
\draw (4,-4.5) -- (4,-5.5) .. controls (4,-6.5) and (4,-6.5) .. (4.5,-6.5) .. controls (5,-6.5) and (5,-6.5) .. (5.5,-6.5) .. controls (6,-6.5) and (6,-6.5) .. (6,-5.5) -- (6,-4.5);
\draw (4,-5.5) -- (6,-5.5);
\draw (8,-1) -- (9,1) -- (10,-1) -- (8,-1);
\begin{scope}[yshift=5cm,rotate=-30]
\draw (13,0.5) rectangle (13.5,2);
\node(fail) at (13,1.25) {};
\draw (13,-2) rectangle (13.5,-0.5);
\draw (14.5,-1) rectangle (16.5,1);
\node[above,rotate=-30] at (15.5,1) {Detector};
\draw (17,-0.5) rectangle (18.5,0.5);
\node[above,rotate=-30] at (17.75,0.5) {Recorder};
\node(detector) at (14.5,0) {};
\draw (16.5,0) -- (17,0);
\node[above,rotate=-30] at (13.25,2) {Slit};
\end{scope}
\draw[densely dashed] (9.5,0) -- (fail);
\draw[densely dashed] (9.5,0) -- (detector);
\node[anchor=north,align=center] at (-1.25,-1.5) {Lamp emits wavelengths of required\\energy to excite electron. The cathode\\of the lamp is the metal to be analysed};
\node[anchor=east,align=right] at (4,-6) {Analyte sample\\in beaker};
\draw (5,-4) -- (4,-4) node[left] {Capillary tube};
\node[align=center] at (9,-2) {monochromator\\and slit select\\light of particular\\wavelength};
\draw[-latex] (4,-2) node[left] {fuel} -- (4.5,-2);
\draw[-latex] (4,-2.5) node[left] {air} -- (4.5,-2.5);
\node at (2.5,0.5) {$P_{0}$};
\node at (7.5,0.5) {$P$};
% Flame goes here:
\shadedraw[bottom color=white,top color=cyan!50!blue] (v1) rectangle (6.5,1.5);
% Terrible Flame:
\shadedraw[bottom color=blue!60!cyan,top color=white,mysine=8pt]
(3.5,-0.5) -- (3.5,0) decorate {(3.5,0) -- (3.7,0.9) -- (3.8,0.1)}
-- (4,0) [mysine=7pt] decorate {(4,0) -- (4,0.9) -- (4.2,0)}
-- (4.5,0) [mysine=9pt] decorate {(4.5,0) -- (4.6,1) -- (4.8,0)}
-- (5,0)[mysine=8pt] decorate {(5,0) -- (5.1,0.9) -- (5.3,0)}
-- (5.5,0) decorate {(5.5,0) -- (5.6,0.9) -- (5.8,0)}
-- (6,0) decorate {(6,0) -- (6.1,0.9) -- (6.3,0)}
-- (6.5,0) -- (6.5,-0.5) --
(3.5,-0.5) -- (3.5,0);
\end{tikzpicture}
\end{document}