summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/rputover/rputover.sty
blob: bfaf166f888f45e14835dad3d488aefe9032c3e8 (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
% rputover.sty
% Version 1.0
% Martin J. Osborne, 2017.3.25
% Based partially on the answer of Werner at
% http://tex.stackexchange.com/questions/353748/is-there-a-variant-of-rput-in-pstricks-that-preserves-background-fill-colors 
% Released under the LaTeX project public license 1.3

\RequirePackage{pst-node}

\newcounter{rpo@pstfiglabel}
\newcounter{rpo@coverable}
\newlength{\rpo@fboxrule}
\setlength{\rpo@fboxrule}{\fboxrule}

\def\rputover{%
  \fboxrule=0pt
  \@ifnextchar[%
          {\@ifnextchar({\@putoveron}{\@putoveror}}%
          {\@ifnextchar({\@putovernn}{\@putovernr}}%
}%

\def\@putoveror[#1]#2(#3,#4)#5{%
  \rput[#1]{#2}(#3,#4){\psDefBoxNodes{label\therpo@pstfiglabel}{\fbox{#5}}}%
  \stepcounter{rpo@pstfiglabel}%
  \setlength{\fboxrule}{\rpo@fboxrule}%
}%

\def\@putoveron[#1](#2,#3)#4{%
  \rput[#1](#2,#3){\psDefBoxNodes{label\therpo@pstfiglabel}{\fbox{#4}}}%
  \stepcounter{rpo@pstfiglabel}%
  \setlength{\fboxrule}{\rpo@fboxrule}%
}%

\def\@putovernr#1(#2,#3)#4{%
  \rput{#1}(#2,#3){\psDefBoxNodes{label\therpo@pstfiglabel}{\fbox{#4}}}%
  \stepcounter{rpo@pstfiglabel}%
  \setlength{\fboxrule}{\rpo@fboxrule}%
}%

\def\@putovernn(#1,#2)#3{%
  \rput(#1,#2){\psDefBoxNodes{label\therpo@pstfiglabel}{\fbox{#3}}}%
  \stepcounter{rpo@pstfiglabel}%
  \setlength{\fboxrule}{\rpo@fboxrule}%
}%

% Optional argument of \coverable is intended to be the region (x0,y0)(x1,y1) with
% respect to which the reverse clip is done.  The default, (-\maxdimen,-\maxdimen)(\maxdimen,\maxdimen),
% seems to work fine, so the possibility of specifying the region manually doesn't seem to be necessary (or useful).
\def\coverable{%
  \@ifnextchar[{\@coverableo}{\@coverablen}%
}%              

\def\@coverableo[(#1,#2)(#3,#4)]#5{\@coverableg{#1}{#2}{#3}{#4}{#5}}
\def\@coverablen#1{\@coverableg{-\maxdimen}{-\maxdimen}{\maxdimen}{\maxdimen}{#1}}

\def\@coverableg#1#2#3#4#5{%
  \psclip{%
    \pscustom[linestyle=none]{%
      \loop%
        \psline[liftpen=2](label\therpo@coverable:bl)(label\therpo@coverable:br)(label\therpo@coverable:tr)(label\therpo@coverable:tl)(label\therpo@coverable:bl)%
        \stepcounter{rpo@coverable}%
        \ifnum\value{rpo@coverable}<\value{rpo@pstfiglabel}%
      \repeat%
      \psline[liftpen=2](#1,#2)(#1,#4)(#3,#4)(#3,#2)%
      }%
    }%
    #5
  \endpsclip%
}