summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pst-hsb/pst-hsb.tex
blob: 975e054fc26d762ca98fa1ec45cda21f51a22ace (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
%% $Id: pst-hsb.tex 350 2021-12-16 10:20:18Z herbert $
%%
%% This is file `pst-hsb.tex',
%%
%% IMPORTANT NOTICE:
%%
%% Package `pst-hsb.tex'
%%
%% Denis Girout
%% Manuel Luque
%% Herbert Voss <hvoss@tug.org>
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `pst-hsb' is a PSTricks package for continous color
%%
%%
\csname PSThsbLoaded\endcsname
\let\PSThsbLoaded\endinput

\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTplotLoaded\endinput\else \input pst-plot \fi
\ifx\PSTXKeyLoaded\endinput\else \input pst-xkey.tex \fi
%
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
% interface to the `xkeyval' package
\pst@addfams{pst-hsb}
%
\def\fileversion{0.02}
\def\filedate{2021/12/16}
\message{`PST-hsb' v\fileversion, \filedate\space (hv)}
%
\define@key[psset]{pst-hsb}{HueBegin}{\def\psparametricplotHSB@HueBegin{#1}}% Between 0 and 1
\define@key[psset]{pst-hsb}{HueEnd}{\def\psparametricplotHSB@HueEnd{#1}}% Between 0 and 1
\define@boolkey[psset]{pst-hsb}[Pst@]{HSB}[true]{}
% Default values
\psset[pst-hsb]{HueBegin=0,HueEnd=1,HSB=true}
\psset{dimen=outer}
 
\def\psparametricplotHSB{\pst@object{psparametricplotHSB}}
\def\psparametricplotHSB@i#1#2#3{{%
  \begin@ClosedObj
  \addto@pscode{%
    /t #1 def
    /dt #2 t sub \psk@plotpoints\space div def
    /t t dt sub def
    /F@pstplot 
      \ifPst@algebraic (#3)
         \ifx\psk@PlotDerivative\@none\else
           \psk@PlotDerivative\space { (t) tx@Derive begin Derive end } repeat
         \fi
         tx@AlgToPs begin AlgToPs end cvx
      \else 
         { #3 } 
      \fi  
    def
    /Counter 0 def
    1 setlinejoin
    \psk@plotpoints {
      /t t dt add def
      /Counter Counter 1 add def
      t F@pstplot
      \pst@number\psyunit mul exch
      \pst@number\psxunit mul exch
      1 Counter eq { moveto currentpoint /OldY ED /OldX ED } % First point
        {\ifPst@HSB % Other points than the first one
          /PointY exch def
          /PointX exch def
          Counter \psk@plotpoints\space div
          \psparametricplotHSB@HueEnd\space
          \psparametricplotHSB@HueBegin\space sub mul
          \psparametricplotHSB@HueBegin\space add
          1 1 sethsbcolor
          OldX OldY PointX PointY lineto lineto 
          stroke
          PointX PointY moveto
          /OldX PointX def /OldY PointY def
        \else lineto \fi } ifelse
     } repeat }% fin du code ps
   \end@ClosedObj
   }\ignorespaces} 
%
\def\pslineHSB{\pst@object{pslineHSB}}
\def\pslineHSB@i(#1)(#2){{%
  \begin@OpenObj
  \pst@getcoor{#1}\pst@tempA
  \pst@getcoor{#2}\pst@tempB
  \addto@pscode{%
    \pst@tempA 
    /y0 ED /x0 ED
    \pst@tempB 
    /y1 ED /x1 ED
    /dx x1 x0 sub \psk@plotpoints\space div def
    /m y1 y0 sub x1 x0 sub div def
    /t x0 dx sub def
    /Counter 0 def
    gsave
    x0 y0 translate
    \psk@plotpoints {
      /t t dx add def
      /Counter Counter 1 add def
      t dup m mul
      1 Counter eq 
        { moveto currentpoint /OldY ED /OldX ED } % First point
        {\ifPst@HSB % Other points than the first one
          /PointY exch def
          /PointX exch def
          Counter \psk@plotpoints\space div
          \psparametricplotHSB@HueEnd\space
          \psparametricplotHSB@HueBegin\space sub mul
          \psparametricplotHSB@HueBegin\space add
          1 1 sethsbcolor
          OldX OldY PointX PointY lineto lineto 
          stroke
          PointX PointY moveto
	  /OldX PointX def /OldY PointY def
         \else lineto \fi 
        } ifelse
     } repeat 
     grestore
   }%
   \end@OpenObj
   }\ignorespaces} 
\catcode`\@=\TheAtCode\relax
%
\endinput
%%
%% END pst-hsb.tex