Post by Konrad VilterstenI understand one can show-off by gradientally use
different colors on an area. Now, i'd like to display
something like that but on a \psline. However, entering
fillstyle=gradient there has no effect (which, of
course, was expected). How can i get there?
Note - if it's doable but complicated i'll be equally
happy drawing a rectangle with gradient color, which
is something i know how to do.
Konrad,
I recently asked the same question on the PStricks mailing list. I
include my request and respons from Manuel Luque, who supplied code
that compiles and produces HSB colored lines - I could easily adapt to
code to print black-and-white lines, but not as complicated as I
originally asked in my post on the mailing list. However, I would like
this feature to be included in a future version of PStricks - it seems
to be an easy/natural extension that could be incorporated...even with
the included code below.
Werner
[-------------8<-------------8<-------------8<-------------]
Hi all,
I'm interested in producing lines in PStricks by means of \psline,
\pcline or \ncline with a gradient line color, similar to the gradient
fills available through the pst-grad and pst-slpe packages. For
example, using the notation of the pst-slpe package, I would like to
do something like:
\psline[linestyle=slope,slopebegin=white,slopeend=black,linewidth=0.5pt]
(0,0)(5,0)
Does there exist a package allowing such line styles? Also, is this
possible with something like \pscurve, for example? Even more, if such
a line style exists, is it possible to make it work with options like
the following:
fillstyle=slopes,slopecolors=0 1 1 1 1 0 0 0 2 1 1 1 3
My current (robust and inadequate) solution makes use of pst-slpe in a
psframe in the following manner:
\psframe[yunit=0.5pt,linestyle=none,fillstyle=slope,slopebegin=white,slopeend=black]
(0,0)(1,1)
This will only hold for straight lines, however. Is there something
better?
Thanks for any help,
Werner
[-------------8<-------------8<-------------8<-------------]
Here a test, of 2003, but which answers, I think, with your
question.
With you to adapt it, possibly...
\documentclass[a4paper]{article}
\usepackage[height=25cm,width=17cm]{geometry}
\usepackage[latin1]{inputenc}
\usepackage{pstricks,pst-xkey,pst-plot}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Essai de Manuel Luque 19 février 2003
% transformé par Denis Girou le 25 février 2003
% révisé le 9 mai 2007
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\***@addfams{pst-HSB}
\***@key[psset]{pst-HSB}{HueBegin}{% Between 0 and 1
\edef\***@HueBegin{#1}}
\***@key[psset]{pst-HSB}{HueEnd}{% Between 0 and 1
\edef\***@HueEnd{#1}}
\newif\***@HSB
\***@key[psset]{pst-HSB}{HSB}[true]{\@nameuse{***@HSB#1}}
% Default values
\psset[pst-HSB]{HueBegin=0,HueEnd=1,HSB=true}
\def\parametricplotHSB{\***@object{parametricplotHSB}}
\def\***@i{\@ifnextchar[{\***@do}
{\***@do[]}}
\def\***@do[#1]#2#3#4{{%
\psset{#1}%
\***@ClosedObj
\***@pscode{%
/t #2 def
/dt #3 t sub \***@plotpoints\space div def
/t t dt sub def
/Counter 0 def
\***@plotpoints {
/t t dt add def
/Counter Counter 1 add def
#4
\***@number\psyunit mul exch
\***@number\psxunit mul exch
1 Counter eq
{moveto} % First point
{\***@HSB % Other points than the first one
/PointY exch def
/PointX exch def
Counter \***@plotpoints\space div
\***@HueEnd\space
\***@HueBegin\space sub mul
\***@HueBegin\space add
1 1 sethsbcolor
PointX PointY lineto
stroke
PointX PointY moveto
\else
lineto
\fi} ifelse
} repeat}% fin du code ps
\***@ClosedObj}} % fin de la commande PSTricks
\makeatother
% La façon de procéder a été copiée sur pst-plot
\title{Vos courbes aux couleurs de l'arc-en-ciel !}
\author{Denis GIROU, Manuel LUQUE}
\date{19-25 février 2003, révisé le 9 mai 2007}
\begin{document}
\maketitle
Cette commande \verb+\parametricplotHSB+, est dérivée de
\verb+\parametricplot+ du package \texttt{pst-plot} de Timothy Van
Zand.
Elle en reprend l'essentiel.
Elle s'emploie comme celle de \verb+\parametricplot+, mais ne
supporte pas les options de style \verb+linestyle+. Par défaut le
codage
\texttt{HSB=true} est activé, on alors une courbe qui déploie toutes
les
couleurs de l'arc-en-ciel sur sa longueur.
Une nouvelle option : on peut choisir la couleur de début et la
couleur de la fin de la courbe avec les paramètres :
\verb+HueBegin=0,HueEnd=0.5+, par exemple ; les valeurs de
\texttt{H} étant choisies entre 0 et 1.
Avec l'option \texttt{HSB=false}, les options de couleurs classiques
redeviennent opérantes.
Le nombre de points se fixe avec le paramètre :
\texttt{plotpoints=1000}
\begin{verbatim}
\begin{pspicture}(0,-4.5)(10,4.5)
\psgrid(0,-4)(10,4)
\psset{plotpoints=300}
\parametricplotHSB[linewidth=1mm,HSB=false,linecolor=red]{0}{360}
{t t 36 div t sin 4 mul}
\parametricplotHSB[linewidth=1mm]{0}{360}{t t 36 div t cos 4 mul}
\end{pspicture}
\end{verbatim}
\begin{center}
\begin{pspicture}(0,-5)(10,5)
\psgrid(0,-4)(10,4)
\psset{plotpoints=300}%
\parametricplotHSB[linewidth=1mm,HSB=false,linecolor=red]{0}{360}
{t t 36 div t sin 4 mul}
\parametricplotHSB[linewidth=1mm]{0}{360}{t t 36 div t cos 4 mul}
\end{pspicture}
\end{center}
\begin{center}
\begin{pspicture}(0,-5)(10,5)
\psgrid(0,-4)(10,4)
\psset{plotpoints=300}%
\parametricplotHSB[linewidth=1mm,HueBegin=0,HueEnd=0.5]{0}{360}
{t t 36 div t sin 4 mul}
\parametricplotHSB[linewidth=1mm,HueBegin=0.5,HueEnd=0.7]{0}{360}
{t t 36 div t cos 4 mul}
\parametricplotHSB[linewidth=1mm,HueBegin=0.8,HueEnd=1]{0}{360}
{t t 36 div t sin 2 mul}
\end{pspicture}
\end{center}
\begin{center}
\begin{pspicture}(-5,-5)(5,5)
\psframe*[linecolor=lightgray](-5,-4)(5,4)
\psgrid[gridlabels=0,subgriddiv=0](-5,-4)(5,4)
\multido{\nxDiv=-5+0.2}{50}{%
\psline(\nxDiv,-.1)(\nxDiv,0.1)}
\multido{\nyDiv=-4.0+0.2}{40}{%
\psline(-0.1,\nyDiv)(0.1,\nyDiv)}
\psset{linewidth=1mm}%
\parametricplotHSB[plotpoints=1000,linecolor=blue,HSB=false,yunit=0.5]
{-5}{5}{%
t
/temps t 2e-3 mul def
/frequence2 100 def
frequence2 360 mul temps mul cos
1 mul 3 add
}
\parametricplotHSB[plotpoints=10000,yunit=1]{-5}{5}{%
t
/temps t 2e-3 mul def
/frequence1 1200 def
/frequence2 100 def
frequence2 360 mul temps mul cos
1 mul 3 add
frequence1 360 mul temps mul cos
4 mul
mul
0.1 mul
}
\end{pspicture}
\end{center}
\end{document}
ML 2007 <***@aol.com>