在哪里可以找到 TikZ 注射器

在哪里可以找到 TikZ 注射器

有谁知道有哪个地方/仓库做过 TikZ 注射器?注射器很复杂,所以我不想重新制作它,但以前肯定有人做过。正在寻找 10 毫升玻璃注射器类型。

答案1

我不知道 TiZ 注射器是存在的,很可能存在。无论如何,这是一个 3D 版本。视角可以改变,但不能任意改变。

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot} 
%\usetikzlibrary{3d,calc}
\begin{document}
\tdplotsetmaincoords{60}{70}
\begin{tikzpicture}[tdplot_main_coords,font=\sffamily,
/tikz/syringe/.cd,
radius/.initial=1,length/.initial=5,tip length/.initial=0.9,tip
radius/.initial=0.2,tip offset/.initial=0.4,
smax/.initial=2,scale/.initial=2,ticks/.initial=10,
extra/.initial=1]
% %  \begin{scope}[xshift=-5cm]
%    \draw[-latex] (0,0,0) -- (1,0,0) node[pos=1.1]{$x$};
%    \draw[-latex] (0,0,0) -- (0,1,0) node[pos=1.1]{$y$};
%    \draw[-latex] (0,0,0) -- (0,0,1) node[pos=1.1]{$z$};
% %  \end{scope}
 %\path[tdplot_screen_coords,use as bounding box] (-3,-3) rectangle (5,3);
 \pgfmathsetmacro\angVis{90+atan(sin(\tdplotmainphi)*cos(\tdplotmaintheta)/sin(\tdplotmaintheta))} 
 \draw[fill=white] plot[variable=\x,domain=0:360,smooth] 
 ({\pgfkeysvalueof{/tikz/syringe/radius}*1.9*cos(\x)},
 \pgfkeysvalueof{/tikz/syringe/length}+\pgfkeysvalueof{/tikz/syringe/extra},
 {\pgfkeysvalueof{/tikz/syringe/radius}*1.4*sin(\x)});
 \draw[fill=white] plot[variable=\x,domain=\angVis:\angVis-180,smooth] 
 ({0.7*\pgfkeysvalueof{/tikz/syringe/radius}*cos(\x)},
 \pgfkeysvalueof{/tikz/syringe/length}+\pgfkeysvalueof{/tikz/syringe/extra},
 {0.7*\pgfkeysvalueof{/tikz/syringe/radius}*sin(\x)})  --
 plot[variable=\x,domain=\angVis-180:\angVis,smooth] 
 ({0.7*\pgfkeysvalueof{/tikz/syringe/radius}*cos(\x)},
 \pgfkeysvalueof{/tikz/syringe/length},
 {0.7*\pgfkeysvalueof{/tikz/syringe/radius}*sin(\x)}) -- cycle;
 % 
 \draw[fill=white] plot[variable=\x,domain=0:360,smooth] 
 ({\pgfkeysvalueof{/tikz/syringe/radius}*1.9*cos(\x)},
 \pgfkeysvalueof{/tikz/syringe/length},
 {\pgfkeysvalueof{/tikz/syringe/radius}*1.4*sin(\x)});
 \draw[fill=white] plot[variable=\x,domain=\angVis:\angVis-180,smooth] 
 ({\pgfkeysvalueof{/tikz/syringe/radius}*cos(\x)},\pgfkeysvalueof{/tikz/syringe/length},{\pgfkeysvalueof{/tikz/syringe/radius}*sin(\x)})  --
 plot[variable=\x,domain=\angVis-180:\angVis,smooth] 
 ({\pgfkeysvalueof{/tikz/syringe/radius}*cos(\x)},0,{\pgfkeysvalueof{/tikz/syringe/radius}*sin(\x)}) -- cycle;
 \draw plot[variable=\x,domain=\angVis:\angVis+180,smooth] 
 ({\pgfkeysvalueof{/tikz/syringe/radius}*cos(\x)},0,{\pgfkeysvalueof{/tikz/syringe/radius}*sin(\x)});
 \draw[fill=white] plot[variable=\x,domain=\angVis:\angVis-180,smooth] 
 ({\pgfkeysvalueof{/tikz/syringe/tip
 radius}*cos(\x)},0,{\pgfkeysvalueof{/tikz/syringe/tip offset}+\pgfkeysvalueof{/tikz/syringe/tip radius}*sin(\x)})  --
 plot[variable=\x,domain=\angVis-180:\angVis,smooth]  
 ({\pgfkeysvalueof{/tikz/syringe/tip radius}*cos(\x)},-1*\pgfkeysvalueof{/tikz/syringe/tip length},{\pgfkeysvalueof{/tikz/syringe/tip offset}+\pgfkeysvalueof{/tikz/syringe/tip radius}*sin(\x)}) -- cycle;
 \draw plot[variable=\x,domain=\angVis+180:\angVis,smooth]  
 ({\pgfkeysvalueof{/tikz/syringe/tip
 radius}*cos(\x)},-1*\pgfkeysvalueof{/tikz/syringe/tip length},{\pgfkeysvalueof{/tikz/syringe/tip offset}+\pgfkeysvalueof{/tikz/syringe/tip radius}*sin(\x)});
 \pgfmathtruncatemacro{\Xmax}{\pgfkeysvalueof{/tikz/syringe/smax}*\pgfkeysvalueof{/tikz/syringe/ticks}}
 \foreach \X in {0,...,\Xmax}
 {\draw plot[variable=\x,domain=-10:10,smooth] 
 ({\pgfkeysvalueof{/tikz/syringe/radius}*cos(\x)},
 \pgfkeysvalueof{/tikz/syringe/scale}*\X/\pgfkeysvalueof{/tikz/syringe/ticks},
 {\pgfkeysvalueof{/tikz/syringe/radius}*sin(\x)});
 }
 \foreach \X in {1,...,\pgfkeysvalueof{/tikz/syringe/smax}}
 {\draw[thick] plot[variable=\x,domain=-15:15,smooth] 
 ({\pgfkeysvalueof{/tikz/syringe/radius}*cos(\x)},
 \pgfkeysvalueof{/tikz/syringe/scale}*\X,
 {\pgfkeysvalueof{/tikz/syringe/radius}*sin(\x)});
 \path let \p1=($({\pgfkeysvalueof{/tikz/syringe/radius}*cos(50)},
 0,{\pgfkeysvalueof{/tikz/syringe/radius}*sin(50)})-
 ({\pgfkeysvalueof{/tikz/syringe/radius}*cos(30)},
 0,{\pgfkeysvalueof{/tikz/syringe/radius}*sin(30)})$),
 \p2=($({\pgfkeysvalueof{/tikz/syringe/radius}*cos(40)},
 1,{\pgfkeysvalueof{/tikz/syringe/radius}*sin(40)})-
 ({\pgfkeysvalueof{/tikz/syringe/radius}*cos(30)},
 0,{\pgfkeysvalueof{/tikz/syringe/radius}*sin(30)})$),
 \n1={atan2(\y1,\x1)-90},
 \n2={veclen(\x1,\y1)/(1cm*\pgfkeysvalueof{/tikz/syringe/radius}*pi/9)} in
 node[rotate=\n1,yscale=\n2] at 
 ({\pgfkeysvalueof{/tikz/syringe/radius}*cos(40)},
 \pgfkeysvalueof{/tikz/syringe/scale}*\X,
 {\pgfkeysvalueof{/tikz/syringe/radius}*sin(40)}) {\X};
 }
\end{tikzpicture}
\end{document} 

在此处输入图片描述

答案2

答案是几年前用 PSTricks 写的。我从这个不错的博客

在此处输入图片描述

\documentclass[pstricks]{standalone}

\usepackage{multido}
\input{random.tex} % From Donald Arseneau (on macros/generic on CTAN)

\def\syringe#1{% position piston -3.5<->-0.5
\psclip{\psframe(#1,-1)(0.8,1)}
\RandomMolecule{400}{#1}
\endpsclip
\psline[doubleline=true,doublesep=2mm](1,0)(3.1,0)
\rput(!#1 -2 sub 0){\pscircle[doubleline=true](-6.5,0){0.6}
\psframe[fillstyle=solid,fillcolor=yellow!10](-6,-0.5)(-2,0.5)
\psline[linewidth=2mm](-2,-1)(-2,1)}%
\psframe(-4,1)(0.8,-1)
\multido{\n=-3.5+0.5}{9}{%
    \psline(\n,1)(\n,0.7)}
    \pscircle[doubleline=true,fillstyle=solid](4,0){1}
    \psarc(4,0){0.65}{-60}{240}
    \multido{\i=-60+30}{11}{\rput(4,0){\psline(0.65;\i)(0.45;\i)}}
    \rput{!337.5 #1 45 mul sub}(4,0){\psline[arrowscale=2,linewidth=2\pslinewidth]{->}(-0.5,0)(0.65,0)}
\psframe[fillstyle=solid](-4.1,-1.2)(-4,1.2)
\psline(0.8,1)(1,0.1)(1,-0.1)(0.8,-1)
}%
% idée empruntée à Denis Girou
\newdimen\X
\newdimen\Y
\def\RandomMolecule#1#2{%
 \multido{\i=1+1}{#1}{%
    \setrandim\X{#2 pt}{1pt}
    \setrandim\Y{-1pt}{1pt}
    \pscircle*[linecolor=blue](\pointless\X,\pointless\Y){1pt}}}

\begin{document}

\multido{\r=-3.5+0.1}{32}{%
\begin{pspicture}(-9,-2)(6,2)
\psframe(-9,-2)(6,2)
\syringe{\r}
\end{pspicture}}
\multido{\r=-0.3+-0.1}{32}{%
\begin{pspicture}(-9,-2)(6,2)
\psframe(-9,-2)(6,2)
\syringe{\r}
\end{pspicture}}

\end{document}

相关内容