summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pst-knot/pst-knot.tex
blob: bf8a8d8ffd441b7cd1aac07a517eeeb5028efe0f (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
%%
%% This is file `pst-knot.tex',
%%
%% IMPORTANT NOTICE:
%%
%% Package `pst-knot.tex'
%%
%% Herbert Voss <herbert -> dante.de>
%%
%% 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-knot' is a PSTricks package for knot macros
%%
%%
\csname PSTknotLoaded\endcsname
\let\PSTknotLoaded\endinput
% Requires PSTricks
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\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-knot}

\def\fileversion{0.02}
\def\filedate{2009/11/08}
\message{`PST-knot' v\fileversion, \filedate\space (hv)}
%
\SpecialCoor
\pstheader{pst-psm.pro}
%
\newdimen\psk@knot@border
\define@key[psset]{pst-knot}{knotborder}[2]{\pssetlength\psk@knot@border{#1}}
\define@key[psset]{pst-knot}{knotbgcolor}[1]{\pst@getcolor{#1}\psk@knot@bgcolor}
\define@key[psset]{pst-knot}{knotscale}[1 1]{\pst@getscale{#1}\psk@knot@scale}
\psset[pst-knot]{knotborder=5\pslinewidth,knotbgcolor=white,knotscale=1}
%
\def\psKnot{\def\pst@par{}\pst@object{psKnot}}
\def\psKnot@i(#1)#2{\expandafter\psKnot@ii(#1)#2}
\def\psKnot@ii(#1)#2-#3{%
  \addto@par{border=.5\pslinewidth}%
  \begin@ClosedObj%
  \pst@getcolor{\pslinecolor}\psk@linecolor%
  \pst@getcoor{#1}\pst@tempA%
  \addto@pscode{
    \pst@tempA\space  moveto
    tx@KnotDict begin 
    PSMinit 
    \psk@knot@scale
    \pst@number\pslinewidth SLW
    \pst@usecolor\psk@linecolor
    /knot-bgline { CLW \pst@number\psk@knot@border add SLW } def
    /knot-bgcolour { \pst@usecolor\psk@knot@bgcolor } def
    knot-#2-#3 \ifnum#2=0 \else knot \fi
    PSMclose 
    end 
  }%
  \end@ClosedObj}
%
\define@key[psset]{pst-knot}{bmcolor}{\expandafter\pst@borromean@color#1,\@nil}
\def\pst@borromean@color#1,#2,#3,\@nil{%
  \pst@getcolor{#1}\psk@borromean@colorA%
  \pst@getcolor{#2}\psk@borromean@colorB%
  \pst@getcolor{#3}\psk@borromean@colorC%
}
\psset[pst-knot]{bmcolor={red,green,blue}}
%
\def\psBorromean{\def\pst@par{}\pst@object{psBorromean}}
\def\psBorromean@i(#1)#2#3{%
%  \addbefore@par{knotborder=3}%
  \begin@ClosedObj%
  \pst@getcoor{#1}\pst@tempA%
  \pst@getcolor{\pslinecolor}\psk@linecolor%
  \pssetlength\pst@dima{#2}%
  \pssetlength\pst@dimb{#3}%
  \addto@pscode{
    tx@KnotDict begin 
    PSMinit 
    \pst@tempA\space translate
    \psk@knot@scale
    /rgb {} def /gray {} def /cmyk {} def
    \pst@number\pslinewidth SLW
    \pst@usecolor\psk@linecolor
    /r \pst@number\pst@dima def % circle radius
    /R \pst@number\pst@dimb def % inner circle radius
    /c1 [R  90] p2r def
    /c2 [R 210] p2r def
    /c3 [R 330] p2r def
    /knot-bgline { CLW \pst@number\psk@knot@border add SLW } def
    /knot-bgcolour {\pst@usecolor\psk@knot@bgcolor} def
    /stroke-shaded {
      gsave knot-bgline knot-bgcolour stroke grestore stroke 
    } def
    c1 r circle \pst@usecolor\psk@borromean@colorA stroke 
    c2 r circle \pst@usecolor\psk@borromean@colorB stroke-shaded 
    c3 r circle \pst@usecolor\psk@borromean@colorC stroke-shaded 
    c1 r -30 30 arc \pst@usecolor\psk@borromean@colorA stroke-shaded 
    c1 r -150 -90 arc stroke-shaded
    PSMclose 
    end 
  }%
  \end@ClosedObj}
%
\catcode`\@=\PstAtCode\relax
%
%% END: pst-knot.tex
\endinput
%