[pstricks] Brace as node connector?
Herbert Voss
Herbert.Voss at alumni.TU-Berlin.DE
Mon Sep 29 21:45:24 CEST 2003
Christian Stork schrieb:
>
> I was wondering if somebody has some macros to use braces as node
> connectors. This would be a very nice feature, which I would use quite
> often. :-)
hope this helps ...
Herbert
\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{pst-key}
\parindent=0pt
\SpecialCoor
\makeatletter
\define at key{psset}{braceWidth}{%
\edef\psk at braceWidth{#1}%
}
\setkeys{psset}{braceWidth=0.35}
%
\def\psbrace{\@ifnextchar[{\@psbrace}{\@psbrace[]}}
\def\@psbrace[#1](#2)(#3){{
\setkeys{psset}{linearc=0.2,linewidth=1pt}% the default
\setkeys{psset}{#1}%
\pst at getcoor{#2}\pst at tempa%
\pst at getcoor{#3}\pst at tempb%
\pnode(!%
/bW2 \psk at braceWidth\space 2.0 div def
\pst at tempa /YA exch \pst at number\psyunit div def
/XA exch \pst at number\psxunit div def
\pst at tempb /YB exch \pst at number\psyunit div def
/XB exch \pst at number\psxunit div def
/Alpha YB YA sub XB XA sub atan def
/xMid XB XA add 2.0 div def
/yMid YB YA add 2.0 div def
/deltaX Alpha sin bW2 mul def
/deltaY Alpha cos bW2 mul def
/xTemp xMid deltaX add def
/yTemp yMid deltaY sub def
xTemp yTemp){@tempNode}
\psline(#2)%
(! XA deltaX add YA deltaY sub)%\\
(@tempNode)%
(! xTemp deltaX add yTemp deltaY sub)%
(@tempNode)%
(! XB deltaX add YB deltaY sub)%
(#3)%
}}
\makeatother
\begin{document}
\begin{pspicture}(10,10)
\psgrid[subgriddiv=0,griddots=10]
\pnode(0,0){A}
\pnode(4,6){B}
\psbrace(A)(B)
\psbrace(B)(A)
\psbrace[braceWidth=1](8,1)(1,7)
\psbrace[braceWidth=-1](8,1)(1,7)
\psbrace[linecolor=red,linewidth=2pt](8,1)(8,9)
\end{pspicture}
\end{document}
--
http://www.pstricks.de/
More information about the PSTricks
mailing list