[pstricks] Linewidth as postscript parameter
Poul Riis
poul.riis at skolekom.dk
Wed Sep 23 15:43:18 CEST 2015
Here is a pstricks workaround of the twisted wires that I wanted. But
still, in general I would be happy if all pstricks parameters could be
defined from postscript values.
Poul Riis
\documentclass[a4paper]{article}
\usepackage[svgnames,x11names]{xcolor}
\usepackage{pstricks-add}
\usepackage{multido}
\usepackage[top=2cm,bottom=1.5cm,left=1.5cm,right=0.5cm]{geometry}
\newcommand{\psTwisting}[6]{%startpointx,startpointy,linewidth, number of
twists (one half twist added at the ends), color1, color2
\psset{linewidth=#3}
\pstVerb{%
/lw #3 def
/xws #1 def
/yws #2 def
/nmax #4 def
/xws1 xws lw 2 div sub def
/xws2 xws lw 2 div add def
/amp lw 2 div def
/lambda lw 10 mul def
/npts 36 def
/deltat 1 npts div def
/lambda1 lambda 10 mul def
/amp1 amp 100 mul def
}%
\pnode(!xws1 yws){P1}
\pnode(!xws1 lw add yws lambda 2 div sub){P2}
\nccurve[angleA=270,angleB=90,ncurv=1,linecolor=#5]{-}{P1}{P2}
\multido{\nn=0+1}{#4}{
\pnode(!xws2 yws lambda \nn\space mul sub){P1}
\pnode(!xws2 lw sub yws lambda \nn\space mul sub lambda 2 div sub){P2}
\pnode(!xws2 yws lambda \nn\space mul sub lambda sub){P3}
\nccurve[angleA=270,angleB=90,ncurv=1,linecolor=#6]{-}{P1}{P2}
\nccurve[angleA=270,angleB=90,ncurv=1,linecolor=#6]{-}{P2}{P3}
\pnode(!xws2 yws lambda \nn\space mul sub lambda 2 div sub){P1}
\pnode(!xws2 lw sub yws lambda \nn\space mul sub lambda 2 div sub lambda
2 div sub){P2}
\pnode(!xws2 yws lambda \nn\space mul sub lambda sub lambda 2 div sub){P3}
\nccurve[angleA=270,angleB=90,ncurv=1,linecolor=#5]{-}{P1}{P2}
\nccurve[angleA=270,angleB=90,ncurv=1,linecolor=#5]{-}{P2}{P3}
}
\pnode(!xws2 yws lambda nmax mul sub){P1}
\pnode(!xws2 lw sub yws lambda nmax mul sub lambda 2 div sub){P2}
\nccurve[angleA=270,angleB=90,ncurv=1,linecolor=#6]{-}{P1}{P2}
\pnode(!xws1 yws){P1}
\pnode(!xws1 amp1 sub yws lambda1 2 div add){Ll}
\nccurve[angleA=90,angleB=270,ncurv=1,linecolor=#5]{-}{P1}{Ll}
\pnode(!xws2 yws){P1}
\pnode(!xws2 amp1 add yws lambda1 2 div add){Lr}
\nccurve[angleA=90,angleB=270,ncurv=1,linecolor=#6]{-}{P1}{Lr}
}%Now leads can be connected to points Ll and Lr...
\parindent=0pt
\thispagestyle{empty}
\begin{document}
~\\
\psset{unit=1cm}
\begin{center}
\begin{pspicture}(-8,-10)(8,8)
%\psaxes(0,0)(-8,-10)(8,8)
\psTwisting{0}{0}{0.1}{6}{Coral2}{Ivory4}%startpointx,startpointy,linewidth,
number of twists (one half twist added at the ends), color1, color2
\end{pspicture}
\end{center}
\end{document}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20150923/d1b905d5/attachment-0003.html>
More information about the PSTricks
mailing list