[pstricks] Linewidth as postscript parameter

Poul Riis poul.riis at skolekom.dk
Tue Sep 22 12:44:45 CEST 2015


What I intend to do is something like this but using more pstricks
commands (still under development - the ends should be strictly
horizontal; more paramaters should be included (wave length, number of
waves, direction)).

Poul Riis


\documentclass[a4paper]{article}
\usepackage[svgnames,x11names]{xcolor}
\usepackage{pstricks-add}
\usepackage{geometry}
\hoffset=-0.5cm
\makeatletter
\def\psTwisting{\pst at object{psTwisting}}
\def\psTwisting at i#1#2#3{%startpointx,startpointy,linewidth
   \begin at SpecialObj
   \addto at pscode{
     /Times-Roman findfont 0.03 scalefont setfont
   /cminpt 72.27 2.54 div def
   /scalefactor cminpt def
scalefactor scalefactor scale
/sometext 20 string def
/lw #3 def
/xws #1 def
/yws #2 def
/xws1 xws lw 2 div sub def
/xws2 xws lw 2 div add def
/amp lw 2 div def
/lambda lw 4 mul def
/npts 36 def
/deltat 1 npts div def
%0.01 setlinewidth
%0.9 0.5 0.7 sethsbcolor
/frame
{newpath
xws lw add yws moveto
xws lw add yws lambda 2.5 mul sub lineto
xws lw sub yws lambda 2.5 mul sub lineto
xws lw sub yws lineto
closepath} def
%0.01 setlinewidth
%0.8 0.6 0.7 sethsbcolor
%frame
%clip
lw setlinewidth
0.6 0.9 1 sethsbcolor
/tt 0 def
xws1 yws moveto 
0 1 npts 2 div 1 add {tt deltat add /tt exch def tt 360 mul cos neg amp
mul xws add tt lambda mul neg yws add lineto } for stroke
0.3 0.9 1 sethsbcolor
/tt 0 def
tt deltat add /tt exch def tt 360 mul cos amp mul xws add tt lambda mul
neg yws add moveto
0 1 npts {tt deltat add /tt exch def tt 360 mul cos amp mul xws add tt
lambda mul neg yws add lineto} for stroke
0.6 0.9 1 sethsbcolor
/tt 0.5 def
tt deltat add /tt exch def tt 360 mul cos neg amp mul xws add tt lambda
mul neg yws add moveto
0 1 npts {tt deltat add /tt exch def tt 360 mul cos neg amp mul xws add tt
lambda mul neg yws add lineto} for stroke
0.3 0.9 1 sethsbcolor
/tt 1 def
tt deltat add /tt exch def tt 360 mul cos amp mul xws add tt lambda mul
neg yws add moveto
0 1 npts {tt deltat add /tt exch def tt 360 mul cos amp mul xws add tt
lambda mul neg yws add lineto} for stroke
0.6 0.9 1 sethsbcolor
/tt 1.5 def
tt deltat add /tt exch def tt 360 mul cos neg amp mul xws add tt lambda
mul neg yws add moveto
0 1 npts {tt deltat add /tt exch def tt 360 mul cos neg amp mul xws add tt
lambda mul neg yws add lineto} for stroke
0.3 0.9 1 sethsbcolor
/tt 2 def
tt deltat add /tt exch def tt 360 mul cos amp mul xws add tt lambda mul
neg yws add moveto
0 1 npts 2 div {tt deltat add /tt exch def tt 360 mul cos amp mul xws add
tt lambda mul neg yws add lineto} for stroke
}
   \end at SpecialObj}
\makeatother

\parindent=0pt
\thispagestyle{empty}

\begin{document}
~\\
\psset{unit=1cm}
\begin{center}
\begin{pspicture}(-8,-10)(8,3)
  \psTwisting{1}{2}{1}%startpointx,startpointy,linewidth
\end{pspicture}
\end{center}
\end{document}


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20150922/8da8a8fd/attachment-0003.html>


More information about the PSTricks mailing list