0

Anyone know of a place/repository that has done a TikZ syringe? A syringe is complicated, so I don't want to recreate it, but it has to have been done before. Looking for a 10 mL glass syringe type.

  • What prevents you from doing a google picture search with site:TeX.stackexchange.com in it? – user121799 May 4 '19 at 2:34
  • I tried that, and didn't find anything. Please link to it if you have! – RJP May 4 '19 at 2:35
7

I do not know if a TikZ syringe exists, most likely it does. Anyway, here is a 3D version. The view angles can be changed but not arbitrarily.

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

enter image description here

| improve this answer | |
4

The answer has been written with PSTricks several years ago. I stole it from this nice blog.

enter image description here

\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}
| improve this answer | |
  • How do I implement this? I'm using Overleaf, and I copied all of the text before the document was begun before I started my document, and placed all the document text in my document, and it threw a bunch of errors. – RJP May 4 '19 at 2:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.