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
|
\ProvidesPackage{pgfheaps}[2004/01/26 ver 0.11]
% Copyright 2003 by Till Tantau <tantau@cs.tu-berlin.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.
\RequirePackage{pgf}
\ProcessOptions
%
% Package for drawing heap diagrams.
%
\newdimen\pgf@heapx
\newdimen\pgf@heapy
% Construct the path of a heap.
%
% #1 = Position of heap label.
% #2 = Position of left base
% #3 = Position of right base
%
% Example:
%
% \pgfheappath{\pgfxy(1,0)}{\pgfxy(-1,0)}{\pgfxy(1,0)}
% \pgffill
\def\pgfheappath#1#2#3{%
\pgfdiff{#2}{#3}%
\pgf@heapx=-.25\pgf@x%
\pgf@heapy=-.25\pgf@y%
\pgfmoveto{#2}%
\pgfbezier%
{\pgfpartway{0.5}{#2}{\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}}%
{\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}%
{#1}%
\pgf@heapx=-\pgf@heapx%
\pgf@heapy=-\pgf@heapy%
\pgfbezier%
{\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}%
{\pgfpartway{0.5}{#3}{\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}}%
{#3}%
\ignorespaces}
% Draw a heap label.
%
% #1 = Position of heap label.
% #2 = Label text.
%
% Example:
%
% \pgfheaplabel{\pgfxy(1,0)}{Class P}
\def\pgfheaplabel#1#2{%
\setbox\pgf@hbox=\hbox{\selectfont#2}%
\pgf@heapy=\ht\pgf@hbox%
\pgfputat{\pgfrelative{#1}{\pgfpoint{0pt}{-2\pgf@heapy}}}{\pgfbox[center,base]{#2}}%
\ignorespaces}
% Draw a labeled heap.
%
% #1 = Position of heap label.
% #2 = Position of left base
% #3 = Position of right base
% #4 = Label text.
%
% Example:
%
% \pgfheaplabeled{\pgfxy(1,0)}{\pgfxy(-1,0)}{\pgfxy(1,0)}{Class P}
\def\pgfheaplabeled#1#2#3#4{%
\pgfheaplabel{#1}{#4}%
\pgfheappath{#1}{#2}{#3}%
\pgfstroke%
\ignorespaces}
% Draw a labeled heap.
%
% #1 = Height of the label
% #2 = Left and right extension of the base.
% #3 = Label text.
%
% Example:
%
% \pgfheaplabeledcentered{1cm}{1cm}{Class P}
\def\pgfheaplabeledcentered#1#2#3{%
\pgfheaplabeled{\pgfpoint{0pt}{#1}}{\pgfpoint{-#2}{0pt}}{\pgfpoint{#2}{0pt}}{#3}\ignorespaces}
\endinput
|