我正在尝试使用乳胶绘制相同的图形,
知道从哪儿开始吗?
更新,我尝试了以下代码..它并不接近我想要的
\documentclass[border=10pt,tikz]{standalone}
\usepackage{xcolor}
\definecolor{lava}{rgb}{0.81, 0.06, 0.13}
\definecolor{myblue}{rgb}{0.0, 0.30, 0.60}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning}
\usepackage{rotating}
\begin{document}
\begin{tikzpicture}
\draw [fill=white, fill opacity=.05,line width=0.0mm]
(180:5mm) coordinate (a)
-- ++(0,3mm) coordinate (b)
arc (180:360:5mm and 1.75mm) coordinate (d)
-- (a -| d) coordinate (c) ;
\draw [fill=white, fill opacity=.05,line width=0.0mm]
(0,0) coordinate (t) circle (5mm and 1.75mm);
\draw [line width=0.0mm] (d) arc (0:180:5mm and 1.75mm);
\draw [fill=white, fill opacity=.05,line width=0.0mm]
(-.5mm,0.25) coordinate (a2)
-- ++(0,4mm) coordinate (b2)
arc (180:360:.5mm and 0.15mm) coordinate (d2)
-- (a2 -| d2) coordinate (c2) arc (0:180:.5mm and 0.15mm);
\draw [fill=white, fill opacity=.5,line width=0.0mm]
(0,0.25) coordinate (t) circle (.5mm and 0.15mm);
\draw [dashed,line width=0.0mm] (d2) arc (0:180:.5mm and 0.15mm);
\draw [line width=0.0mm]
(0,0) coordinate (T) circle (7.5mm and 2.625mm);
\draw [fill=myblue, fill opacity=.05,line width=0.0mm]
(180:7.5mm) coordinate (A)
-- ++(0,-5.5mm) coordinate (B) node [midway, right, inner sep=1pt] {}
arc (180:360:7.5mm and 2.625mm) coordinate (D)
-- (A -| D) coordinate (C) arc (0:180:7.5mm and 2.625mm);
\draw [line width=0.0mm] (D) arc (0:180:7.5mm and 2.625mm);
-- (T) node [midway, right, anchor=west, fill=white, inner sep=.5pt] {} node [anchor=center, circle, draw, solid, inner sep=.5pt, fill=white] {} edge [solid, -Latex] node [right, pos=1] {} ++(0,5mm) ;
\end{tikzpicture}
\end{document}
任何能使其看起来更好的调整都会受到赞赏。
答案1
可能最好的解决方案是使用该shapes.geometric
库,并执行类似于此处指示的操作:更多关于“使用 pgf TiKZ 进行圆柱着色”的信息。
但是,回收我之前绘制的一张涉及圆柱体的图纸,我可以为您提供另一种选择,如下所示:
\documentclass[border=2mm]{standalone}
\usepackage {ifthen}
\usepackage {tikz}
\usetikzlibrary{calc}
\newcommand{\cylinder}[5] % center, radius (y-axis), height (to the right), color, opacity
{
\pgfmathsetmacro\r {0.5*#2} % radius (x-axis)
\coordinate (C1) at #1; % center, left ellipse
\coordinate (N1) at ($(C1)+(0,#2)$); % north, left ellipse
\coordinate (NW1) at ($(C1)+(-\r,#2)$); % north west, left ellipse
\coordinate (W1) at ($(C1)-(\r,0)$); % west, left ellipse
\coordinate (S1) at ($(C1)-(0,#2)$); % south, left ellipse
\coordinate (P1) at ($(W1)!0.1!(NW1)$); % point for shading
\coordinate (Q1) at ($(W1)!0.2!(NW1)$); % another point for shading
\coordinate (C2) at ($(C1)+(#3,0)$); % center, right ellipse
\coordinate (N2) at ($(N1)+(#3,0)$); % ...
\coordinate (S2) at ($(S1)+(#3,0)$);
\coordinate (P2) at ($(P1)+(#3,0)$);
\ifthenelse
{\equal{#3}{0}} % if height is 0
{} % then do nothing
{ % else...
\begin{scope}
\clip (N1) arc (90:270:\r cm and #2 cm) -- (S2) -- (S2) arc (270:90:\r cm and #2 cm) -- cycle;
\shade[top color=white, bottom color=#4!65,fill opacity=#5] (S2) rectangle (P1);
\shade[top color=#4!55, bottom color=white,fill opacity=#5] (N2) rectangle (Q1);
\fill[white, opacity=#5] (P2) rectangle (Q1);
\end{scope}
\draw[#4] (N2) -- (N1) arc (90:270:\r cm and #2 cm) -- (S2);
}
\draw[#4,fill=#4!12.5,opacity=#5] (C2) ellipse (\r cm and #2 cm);
}
\begin{document}
\begin{tikzpicture}[scale=2,line cap=round,line join=round]
\cylinder{(0,0)}{0.75}{2}{blue} {1};
\cylinder{(0,0)}{1} {2}{black}{0.75};
\cylinder{(2,0)}{0.75}{1}{blue} {1};
\cylinder{(3,0)}{0.1} {0}{red} {1};
\fill(3,0) circle (0.25pt);
\draw[very thin,dashed] (2,1) -- (3.5,1);
\draw[very thin,dashed] (3,0.75) -- (4,0.75);
\draw[very thin,dashed] (3,0.1) -- (3.6,0.1);
\draw[very thin,dashed] (3,0) -- (4,0);
\draw[-latex] (3.5,1) node [above right] {Refractive index} -- (6,1);
\draw[red!80!black] (3.7,1) |- (3.6,0.75) |- (4,0.1) -- (4,0);
\node at (4,0.875) [right] {Coating};
\node at (4,0.425) [right] {Cladding};
\node at (4,0.05) [right] {Core};
\end{tikzpicture}
\end{document}