我想通过执行不同的操作 x、y、z 来可视化从状态 A 到状态 B 的转换。我想实现类似这样的效果:
________ ________
| | ____ _____ ____ | |
| | | \ \ \ | |
| A | | x | y | z | | B |
| | |____/_____/____/ | |
|________| |________|
我知道如何在 tikz 中绘制这些块,但我不确定是否已经有一些现有功能提供了一种简单的方法来做到这一点。我想以一种简单的方式删除/添加/设置块的样式。我还想把它放在圆角矩形中:
__________________
( \ \ \ )
(___/____/____/____)
有一个圆形的箭头链也是很好的。
如果没有现有的解决方案,我感兴趣的是如何为这个问题创建一个好的、可重复使用的解决方案的建议。
答案1
您可以使用一些signal
带有 null 的形状distance node
。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains,positioning,shapes.symbols}
\begin{document}
\begin{tikzpicture}
\tikzset{
bound/.style={
draw,
minimum height=2cm,
inner sep=1em,
},
arrow/.style={
draw,
minimum height=1cm,
inner sep=1em,
shape=signal,
signal from=west,
signal to=east,
signal pointer angle=110,
}
}
\node[bound] (a) {A};
\begin{scope}[start chain=transition going right,node distance=-\pgflinewidth]
\node[arrow,right=1cm of a,on chain] {first};
\node[arrow,on chain] {second};
\node[arrow,on chain] {third};
\end{scope}
\node[bound,right=1cm of transition-end]{B};
\end{tikzpicture}
\end{document}
答案2
您可以使用\usetikzlibrary{shapes,decorations.shapes}
例如pgfmanual
p.335如下
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,decorations.shapes}
\begin{document}
\begin{tikzpicture}[
decoration={shape backgrounds,shape size=.5cm,shape=signal},
signal from=west, signal to=east,
paint/.style={decorate, draw=#1!50!black, fill=#1!50}]
\draw [help lines] grid (3,2);
\draw [paint=red, decoration={shape sep=.5cm}]
(0,2) -- (3,2);
\draw [paint=green, decoration={shape sep={1cm, between centers}}]
(0,1) -- (3,1);
\draw [paint=blue, decoration={shape sep={1cm, between borders}}]
(0,0) -- (3,0);
\end{tikzpicture}
\end{document}
但是我在两个节点之间遇到了问题(缺少偏移量),但我确信有人会改进下面的代码:
\begin{tikzpicture}[
decoration={shape backgrounds,shape size=1cm,shape=signal},
signal from=west, signal to=east,
paint/.style={decorate, draw=#1!50!black, fill=#1!50}]
\node[draw,minimum height=2cm,minimum width=2cm](A)at (0,0) {A};
\node[draw,minimum height=2cm](B)at(5,0){B};
\draw [paint=red, decoration={shape sep=1cm},]
(A)-- (B);
\end{tikzpicture}