我正在尝试使用 tikz 绘制下面的图像。
有没有简单的方法可以做到这一点?谢谢
答案1
作为报告格式说,你可能不想使用node
形状乌,这会相当复杂。不过,你可以利用它nodes
得到正确的形状:
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[
workerWidth/.style={minimum width=3cm},
workerHeight/.style={minimum height=2cm},
UWidth/.style={minimum width=1cm},
every node/.style={
text centered,
},
thick
]
\node[workerWidth, workerHeight, draw] (worker) at (0, 0) {Worker};
\node[anchor=north, workerWidth, yshift=-0.5cm] (cache) at (worker.south) {Cache};
\node[anchor=east, workerHeight, UWidth, xshift=-1cm] (left) at (worker.west) {};
\node[anchor=west, workerHeight, UWidth, xshift=1cm] (right) at (worker.east) {};
\draw (left.north west) -- (left.west |- cache.south) -- (right.east |- cache.south) -- (right.north east) -- (right.north west) -- (right.west |- cache.north) -- (left.east |- cache.north) -- (left.north east) -- cycle;
\draw[<-, >={Latex}] (left.west) -- ++(-1, 0);
\draw[->, >={Latex}] (left.east) -- (worker.west);
\draw[->, >={Latex}] (worker.east) -- (right.west);
\draw[->, >={Latex}] (right.east) -- ++(1, 0);
\end{tikzpicture}
\end{document}
从这三个锚点开始,nodes
它使用它们的基础锚点来构建乌形状,而样式确保所有节点nodes
都有正确的大小(您可以为每个节点手动执行此操作,但这种方式可以确保一致性)。
如果你真的想要乌形节点,您可能需要提供更多信息并提供一些起始代码。这些东西相当复杂。