Debian Codegraph @

texmf-dist/tex/latex/pgf/compatibility/pgfheaps.sty

raw
1 % Copyright 2018 by Till Tantau
2 %
3 % This file may be distributed and/or modified
4 %
5 % 1. under the LaTeX Project Public License and/or
6 % 2. under the GNU Public License.
7 %
8 % See the file doc/generic/pgf/licenses/LICENSE for more details.
9
10 \RequirePackage{pgfrcs}
11
12 \ProvidesPackageRCS{pgfheaps.sty}
13
14 \RequirePackage{pgf}
15
16 \PackageWarning{pgfheaps}{This package is obsolete.}
17
18 \ProcessOptions
19
20 %
21 % Package for drawing heap diagrams.
22 %
23
24 \newdimen\pgf@heapx
25 \newdimen\pgf@heapy
26
27
28
29
30 % Construct the path of a heap.
31 %
32 % #1 = Position of heap label.
33 % #2 = Position of left base
34 % #3 = Position of right base
35 %
36 % Example:
37 %
38 % \pgfheappath{\pgfxy(1,0)}{\pgfxy(-1,0)}{\pgfxy(1,0)}
39 % \pgffill
40
41 \def\pgfheappath#1#2#3{%
42 \pgfdiff{#2}{#3}%
43 \pgf@heapx=-.25\pgf@x%
44 \pgf@heapy=-.25\pgf@y%
45 \pgfmoveto{#2}%
46 \pgfbezier%
47 {\pgfpartway{0.5}{#2}{\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}}%
48 {\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}%
49 {#1}%
50 \pgf@heapx=-\pgf@heapx%
51 \pgf@heapy=-\pgf@heapy%
52 \pgfbezier%
53 {\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}%
54 {\pgfpartway{0.5}{#3}{\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}}%
55 {#3}%
56 \ignorespaces}
57
58
59 % Draw a heap label.
60 %
61 % #1 = Position of heap label.
62 % #2 = Label text.
63 %
64 % Example:
65 %
66 % \pgfheaplabel{\pgfxy(1,0)}{Class P}
67
68 \def\pgfheaplabel#1#2{%
69 \setbox\pgf@hbox=\hbox{\pgfinterruptpicture#2\endpgfinterruptpicture}%
70 \pgf@heapy=\ht\pgf@hbox%
71 \pgfputat{\pgfrelative{#1}{\pgfpoint{0pt}{-2\pgf@heapy}}}{\pgfbox[center,base]{#2}}%
72 \ignorespaces}
73
74
75 % Draw a labeled heap.
76 %
77 % #1 = Position of heap label.
78 % #2 = Position of left base
79 % #3 = Position of right base
80 % #4 = Label text.
81 %
82 % Example:
83 %
84 % \pgfheaplabeled{\pgfxy(1,0)}{\pgfxy(-1,0)}{\pgfxy(1,0)}{Class P}
85
86 \def\pgfheaplabeled#1#2#3#4{%
87 \pgfheaplabel{#1}{#4}%
88 \pgfheappath{#1}{#2}{#3}%
89 \pgfstroke%
90 \ignorespaces}
91
92
93
94 % Draw a labeled heap.
95 %
96 % #1 = Height of the label
97 % #2 = Left and right extension of the base.
98 % #3 = Label text.
99 %
100 % Example:
101 %
102 % \pgfheaplabeledcentered{1cm}{1cm}{Class P}
103
104 \def\pgfheaplabeledcentered#1#2#3{%
105 \pgfheaplabeled{\pgfpoint{0pt}{#1}}{\pgfpoint{-#2}{0pt}}{\pgfpoint{#2}{0pt}}{#3}\ignorespaces}
106
107 \endinput