填充曲线图形-液压制动系统

填充曲线图形-液压制动系统

我正在尝试绘制一个简单的液压制动系统。我已经成功制作了一个简单的液压系统。

\documentclass[11pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}   
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.pathmorphing} 
\usepackage{tkz-euclide}
\usetikzlibrary{calc,intersections,through,backgrounds,snakes}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
        \begin{center}
        \begin{tikzpicture}
        \tkzInit[ymin=0,ymax=6.5, xmin=0,xmax=10]
        \tkzClip
        %\tkzGrid
        \tkzDefPoints{1/6/A, 1/1/B, 9/1/C, 9/6/D, 6/6/E, 6/2/F, 2/2/G, 2/6/H};
        \tkzDefPoints{1/5/K, 6/3/L}; 
        \tkzDefPoints{1.5/5/M} 
        \filldraw[black] (K) --+ (1,0) --+ (1,0.5) --+ (0,0.5);
        \filldraw[black] (L) --+ (3,0) --+ (3,0.5) --+ (0,0.5);
        \filldraw[black!40] (K) --+ (1,0) -- (G) -- (F) --(L) --+ (3,0) -- (C) -- (B);
        \draw [thick] (A) -- (B) -- (C) -- (D);
        \draw [thick] (E) -- (F) -- (G) -- (H);
        \draw[->, very thick,red] (K) ++ (0.5,0.5) --+ (0,1); 
        \draw[->, very thick, red] (L) ++ (1.5,0.5) --+ (0,2);
        \node[white, above right] at (K) {$A_1$};
        \node[white, above right] at (L) {$A_2$};
        \end{tikzpicture}
        \end{center}
\end{document}

在此处输入图片描述

但我希望它使管子弯曲,使它变成这样: 在此处输入图片描述

因此,我希望油管弯曲且充满液体,而不是矩形。Tikz 是可行的方法吗?还是我应该寻找其他方法?

答案1

是的,我想你可以使用 TikZ;具有double适当的out=in=就可以完成这项工作;我还使用了一些图层来放置一些元素:

在此处输入图片描述

代码:

\documentclass[border=5pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{fit,arrows.meta}

\definecolor{myorange}{RGB}{206,103,44}
\definecolor{myred}{RGB}{176,24,43}
\definecolor{mybg}{RGB}{166,161,121}

\pgfdeclarelayer{background}
\pgfdeclarelayer{backgroundii}
\pgfsetlayers{backgroundii,background,main}

\begin{document}

\begin{tikzpicture}[
  arr/.style={
    line width=1.5pt,
    Circle-Stealth
  }
]
\begin{scope}[rotate=-30,transform shape]
\node[fill=myorange,text width=3cm,minimum height=40pt] 
  (tube1l)
  {};
\node[fill=myred,text width=1cm,minimum height=40pt,anchor=east,outer sep=0pt] 
  (tube2l)
  at (tube1l.west)
  {};
\begin{pgfonlayer}{background}
\filldraw[white,draw=black]
  ([shift={(0pt,5pt)}]tube2l.center|-tube1l.north west) 
  rectangle
  ([shift={(5pt,-5pt)}]tube1l.south east); 
\end{pgfonlayer}
\end{scope}

\node[fill=myorange,text width=1cm,minimum height=60pt] 
  (tube1r)
  at (20,4) 
  {};
\node[fill=myred,text width=1.5cm,minimum height=60pt,anchor=west,outer sep=0pt] 
  (tube2r)
  at (tube1r.east)
  {};
\begin{pgfonlayer}{background}
\filldraw[white,draw=black]
  ([shift={(0pt,5pt)}]tube2r.center|-tube1r.north east) 
  rectangle
  ([shift={(-5pt,-5pt)}]tube1r.south west); 
\end{pgfonlayer}

\draw[double,double distance=10pt,black,double=myorange]
  (tube1l.east) to[out=-30,in=180] (tube1r.west);  

\draw[arr]
  (tube1l.west) -- (-30:2.3cm);
\draw[arr]
  (tube1r.east) -- ++(2.5cm,0);

\begin{pgfonlayer}{backgroundii}
\fill[mybg]
  (current bounding box.north west)
  rectangle
  (current bounding box.south east);
\end{pgfonlayer}
\end{tikzpicture}

\end{document}

答案2

您可以使用double和朋友。要绘制弯曲的线条,您可以使用plot(就像我一样)或..controlshobby包。

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \draw[thick,double=red!40!brown,double distance=3pt,draw=black]  plot[smooth, tension=.7] coordinates {(-3.5,-1) (-1,-2) (1.5,0) (3,0.9) (4.5,1)};
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容