我正在尝试绘制流程图,我查看了一些软件包。由于我比较熟悉,所以pstricks
我选择了它,并且当我查看示例时,我尝试在环境中绘制它psmatrix
。
我们的老师告诉我们“初始化”应该以平行四边形的形式写出来,而当我尝试在流程图中绘制它时,我不知道应该使用什么语法来表示平行四边形!
有没有什么特定的命令可以做到这一点?
我是否应该使用\psdiabox
特定角度来获得平行四边形?如果是,我应该如何定义角度?
这是我想要绘制的一个例子,其中我想将红色框 - “初始化” - 作为平行四边形而不是矩形。
\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{pst-blur}
\definecolor{Pink}{rgb}{1.,0.75,0.8}
\pagestyle{empty}
\begin{document}
\vspace{0.5cm}
\small
\psset{shadowcolor=black!70,blur=true}
\begin{psmatrix}[rowsep=0.4,colsep=0.5]
\psovalbox{Begin} \\
\psframebox[,fillstyle=solid,fillcolor=red]{Initialisations} \\
\psdiabox{Special} &
\psframebox[shadow=true]{Call to SP1} & \psframebox[shadow=true]{Call to SP2} \\
\psframebox{Action 1} \\
~\\
\psframebox{Action 2} \\
\psovalbox{End}
% Links
\ncline{->}{1,1}{2,1}
\ncline{->}{2,1}{3,1}
\ncline{->}{3,1}{4,1}<{\textcolor{red}{No}}
\ncline{->}{4,1}{6,1}
\ncline{->}{6,1}{7,1}
\ncline{->}{3,1}{3,2}^{\textcolor{red}{Yes}}
\ncline{->}{3,2}{3,3}
\ncbar[angleA=-90,armB=0,nodesepB=0.25]{->}{3,3}{4,1}
\end{document}
答案1
\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node,pst-3d}
\usepackage{pst-blur}
\definecolor{Pink}{rgb}{1.,0.75,0.8}
\makeatletter
\newsavebox\TBox
\newcommand\psParaBox[2][]{{
\psset{framesep=5pt,gangle=60,#1}%
\sbox\TBox{\psTilt{\psk@gangle}{\psframebox{\phantom{ #2}}}}%
\usebox\TBox%
\rput(-0.5\wd\TBox,\dimexpr 0.5\ht\TBox-0.5ex\relax){ #2}}}
\makeatother
\pagestyle{empty}
\begin{document}
\psset{shadowcolor=black!70,blur}
\begin{psmatrix}[rowsep=0.4,colsep=0.5]
\psovalbox{Begin} \\
\psParaBox[fillstyle=solid,fillcolor=red!40]{Initialisations} \\
\psdiabox{Special} &
\psframebox[shadow=true]{Call to SP1} & \psframebox[shadow=true]{Call to SP2} \\
\psframebox{Action 1} \\
~\\
\psframebox{Action 2} \\
\psovalbox{End}
% Links
\ncline{->}{1,1}{2,1}
\ncline{->}{2,1}{3,1}
\ncline{->}{3,1}{4,1}<{\textcolor{red}{No}}
\ncline{->}{4,1}{6,1}
\ncline{->}{6,1}{7,1}
\ncline{->}{3,1}{3,2}^{\textcolor{red}{Yes}}
\ncline{->}{3,2}{3,3}
\ncbar[angleA=-90,armB=0,nodesepB=0.25]{->}{3,3}{4,1}
\end{psmatrix}
\end{document}
答案2
下面的定义\psparallelogram[<options>]{<stuff>}
以相同的方式工作\psdiabox
并\psframebox
起作用:
\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{pst-blur}
\definecolor{Pink}{rgb}{1.,0.75,0.8}
% ================================
% Source: http://tug.org/pipermail/pstricks/2009/006766.html
\makeatletter
\newdimen\psparallelogramsep
\def\psset@parallelogramsep#1{\pssetlength\psparallelogramsep{#1}}
\psset@parallelogramsep{3mm}
\def\psparallelogrambox{\pst@object{psparallelogrambox}}
\def\psparallelogrambox@i{\pst@makebox\psparallelogrambox@ii}
\def\psparallelogrambox@ii{%
\begingroup
\pst@useboxpar
\pst@dima=\pslinewidth
\advance\pst@dima by \psframesep
\pst@dimc=\wd\pst@hbox\advance\pst@dimc by \pst@dima
\pst@dimb=\dp\pst@hbox\advance\pst@dimb by \pst@dima
\pst@dimd=\ht\pst@hbox\advance\pst@dimd by \pst@dima
\setbox\pst@hbox=\hbox{%
\ifpsboxsep\kern\pst@dima\fi
\begin@ClosedObj
\addto@pscode{%
\psk@cornersize
\pst@number\pst@dima neg
\pst@number\pst@dimb neg
\pst@number\pst@dimc
\pst@number\pst@dimd .5
\pst@number\psparallelogramsep
\tx@Parallelogram}%
\def\pst@linetype{2}%
\showpointsfalse
\end@ClosedObj
\box\pst@hbox
\ifpsboxsep\kern\pst@dima\fi%
}%
\ifpsboxsep\dp\pst@hbox=\pst@dimb\ht\pst@hbox=\pst@dimd\fi
\leavevmode\box\pst@hbox
\endgroup%
}
% From the Frame and Rect PostScript macros
\pst@def{Parallelogram}<{%
/ParallelogramA {
x1 pgs sub y1 moveto
x1 y2 lineto
x2 pgs add y2 lineto
x2 y1 lineto
x1 pgs sub y1 lineto
closepath} def
%
/pgs ED
CLW mul
/a ED
3 -1 roll
2 copy gt { exch } if
a sub
/y2 ED
a add
/y1 ED
2 copy gt { exch } if
a sub
/x2 ED
a add
/x1 ED
1 index 0 eq {pop pop ParallelogramA } { OvalFrame } ifelse}>
\makeatother
\def\pspbox[#1]#2{\makebox[#1]{\psparallelogrambox{#2}}}
% ================================
\pagestyle{empty}
\begin{document}
\vspace{0.5cm}
\small
\psset{shadowcolor=black!70,blur=true}
\begin{psmatrix}[rowsep=0.4,colsep=0.5]
\psovalbox{Begin} \\
%\psframebox[fillstyle=solid,fillcolor=red]{Initialisations} \\
\psparallelogrambox[fillstyle=solid,fillcolor=red]{Initialisations} \\
\psdiabox{Special} &
\psframebox[shadow=true]{Call to SP1} & \psframebox[shadow=true]{Call to SP2} \\
\psframebox{Action 1} \\
~\\
\psframebox{Action 2} \\
\psovalbox{End}
% Links
\ncline{->}{1,1}{2,1}
\ncline{->}{2,1}{3,1}
\ncline{->}{3,1}{4,1}<{\textcolor{red}{No}}
\ncline{->}{4,1}{6,1}
\ncline{->}{6,1}{7,1}
\ncline{->}{3,1}{3,2}^{\textcolor{red}{Yes}}
\ncline{->}{3,2}{3,3}
\ncbar[angleA=-90,armB=0,nodesepB=0.25]{->}{3,3}{4,1}
\end{psmatrix}
\end{document}
平行四边形的来源取自 PStricks 邮件条目树中的平行四边形。