[pstricks] ncline
Herbert Voss
Herbert.Voss at alumni.TU-Berlin.DE
Mon Nov 17 17:35:31 CET 2003
Pedro Jorge Caridade schrieb:
> The goal is to draw some line to give the impression of 3D. I could use
> a poligon but calculate the coordinates is very complicated. Since I
> using nodes, with the change of the thick of the line I can get this
> perspective
here is an example for \psline
Herbert
\documentclass[12pt,a4paper]{article}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{pst-key}
\SpecialCoor
\makeatletter
\newdimen\pswBegin\newdimen\pswEnd
\def\psset at wBegin#1{\pssetlength\pswBegin{#1}}
\def\psset at wEnd#1{\pssetlength\pswEnd{#1}}
\setkeys{psset}{wBegin=\pslinewidth, wEnd=\pslinewidth}
%
\def\pslineIII{\@ifnextchar[{\@pslineIII}{\@pslineIII[]}}
\def\@pslineIII[#1](#2)(#3){{
\psset{#1}
\pst at getcoor{#2}\pst at tempa
\pst at getcoor{#3}\pst at tempb
\pnode(!%
\pst at tempa /YA exch def
/XA exch def
\pst at tempb /YB exch def
/XB exch def
/Alpha YB YA sub XB XA sub atan def
/bA2 \pst at number\pswBegin\space 2.0 div def
/bB2 \pst at number\pswEnd\space 2.0 div def
\pst at usecolor\pslinecolor
0.1 SLW
XA YA moveto
XA Alpha sin bA2 mul sub
YA Alpha cos bA2 mul add lineto
XB Alpha sin bB2 mul sub
YB Alpha cos bB2 mul add lineto
XB Alpha sin bB2 mul add
YB Alpha cos bB2 mul sub lineto
XA Alpha sin bA2 mul add
YA Alpha cos bA2 mul sub lineto
XA YA lineto fill stroke XA YA){@tempNodeD}
}}
\makeatother
\begin{document}
\psset{unit=1cm}
\begin{pspicture}(-5,-5)(5,5)
\psgrid[griddots=10, gridlabels=7pt, subgriddiv=0]
%
\pslineIII[wBegin=0.5cm](-5,-3)(5,3)
\pslineIII[wBegin=0.5cm,wEnd=0.1cm,linecolor=red](0,-5)(0,5)
\pslineIII[wBegin=1cm,wEnd=0.3cm,linecolor=blue](-5,5)(5,-4)
%
\end{pspicture}
\end{document}
--
http://www.pstricks.de/
More information about the PSTricks
mailing list