summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/makeshape/makeshape.sty
blob: 1e875325418a924df1673416dfeafaed61e4d6c2 (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
%%
%% This is file `makeshape.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% makeshape.dtx  (with options: `package')
%% 
%% Copyright (C) 2013 by Adrian P Robson
%%    adrian.robson@nepsweb.co.uk
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% 
%% This work has the LPPL maintenance status `maintained'.
%% The Current Maintainer of this work is Adrian Robson.
%% 
%% This work consists of the files makeshape.ins
%%                                 makeshape.dtx and
%%                                 ontesting.dtx
%% and the derived files           makeshape.sty
%%                                 makeshape.pdf
%%                                 sampleshape.tex
%%                                 ontesting.pdf
%%                                 testsample.tex and
%%                                 testsample.pdf
%% 
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\ProvidesPackage{makeshape}
   [2013/01/25 2.1 Making custom shapes for PGF/TikZ]
\RequirePackage{tikz}
\usepgflibrary{intersections}
\def\setpaths#1#2{
   \savedmacro\ctbnex{
      \pgf@x=.5\wd\pgfnodeparttextbox
      \pgfmathsetlength\pgf@xa{\pgfshapeinnerxsep}
      \advance\pgf@x\pgf@xa
      \edef\temp@x{\the\pgf@x}
      \let\ctbnex\temp@x
   }
   \savedmacro\ctbney{
      \pgf@y=.5\ht\pgfnodeparttextbox
      \advance\pgf@y.5\dp\pgfnodeparttextbox
      \pgfmathsetlength\pgf@ya{\pgfshapeinnerysep}
      \advance\pgf@y\pgf@ya
      \edef\temp@y{\the\pgf@y}
      \let\ctbney\temp@y
   }
   \savedmacro\pgfshapeouterxsep{
      \pgfkeysgetvalue{/pgf/outer xsep}{\temp@sep}
      \let\pgfshapeouterxsep\temp@sep
   }
   \savedmacro\pgfshapeouterysep{
      \pgfkeysgetvalue{/pgf/outer ysep}{\temp@sep}
      \let\pgfshapeouterysep\temp@sep
   }
   \savedmacro{\pgfshapeminwidth}{
      \pgfkeysgetvalue{/pgf/minimum width}{\temp@wd}
      \let\pgfshapeminwidth\temp@wd
   }
   \savedmacro{\pgfshapeminheight}{
      \pgfkeysgetvalue{/pgf/minimum height}{\temp@ht}
      \let\pgfshapeminheight\temp@ht
   }
   \savedanchor{\centre}{
      \pgfpointorigin
   }
   \savedanchor{\text}{
      \pgf@y=-0.5\ht\pgfnodeparttextbox
      \advance\pgf@y by 0.5\dp\pgfnodeparttextbox
      \pgf@x=-0.5\wd\pgfnodeparttextbox
   }
   \savedanchor{\boundbox@ne}{
      \pgfusepath{}
      #1
      \pgf@xb=\pgf@pathmaxx
      \pgf@yb=\pgf@pathmaxy
      \pgf@xc=\pgf@pathminx
      \pgf@yc=\pgf@pathminy
      \pgfusepath{}
      \ifdim\pgf@xb<0pt \pgf@xb=-\pgf@xb \fi
      \ifdim\pgf@xc<0pt \pgf@xc=-\pgf@xc \fi
      \ifdim\pgf@xb<\pgf@xc
         \pgf@x=\pgf@xc
      \else
         \pgf@x=\pgf@xb
      \fi
      \ifdim\pgf@yb<0pt \pgf@yb=-\pgf@yb \fi
      \ifdim\pgf@yc<0pt \pgf@yc=-\pgf@yc \fi
      \ifdim\pgf@yb<\pgf@yc
         \pgf@y=\pgf@yc
      \else
         \pgf@y=\pgf@yb
      \fi
   }
   \anchor{center}{\centre}
   \anchor{text}{\text}
   \anchorborder{
      \edef\targpointx{\the\pgf@x}
      \edef\targpointy{\the\pgf@y}
      \pgf@relevantforpicturesizefalse
      \pgftransformreset
      \boundbox@ne
      \pgf@xa=\pgf@x
      \pgf@ya=\pgf@y
      \pgfpointborderrectangle{\pgfpoint{\targpointx}{\targpointy}}
                              {\pgfpoint{\pgf@xa}{\pgf@ya}}
      \edef\corrx{\the\pgf@x}
      \edef\corry{\the\pgf@y}
      \pgfintersectionofpaths {
         #1
      }{
         \pgfpathmoveto{\pgfpoint{0}{0}}
         \pgfpathlineto{\pgfpoint{\corrx}{\corry}}
      }
      \pgfpointintersectionsolution{1}
   }
   \backgroundpath{
      #2
   }
}
\newdimen\crct@dim
\def\mincorrect#1#2{
   \pgfmathsetlength\crct@dim{#2}
   \pgfmathsetlength\crct@dim{0.5\crct@dim}
   \ifdim#1<\crct@dim
      #1=\crct@dim
   \fi
}
\def\path@textbox{
   \pgf@xa=.5\wd\pgfnodeparttextbox
   \pgf@ya=.5\ht\pgfnodeparttextbox
   \advance\pgf@ya.5\dp\pgfnodeparttextbox
   \typeout{**** TEST text box (x,y) = (\the\pgf@xa,\the\pgf@ya) }
   \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
   \pgfpathlineto{\pgfpoint{\pgf@xa}{-\pgf@ya}}
   \pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@ya}}
   \pgfpathlineto{\pgfpoint{-\pgf@xa}{\pgf@ya}}
   \pgfpathclose
}
\def\path@ctextbox{
   \pgf@xa=.5\wd\pgfnodeparttextbox
   \pgfmathsetlength\pgf@xc{\pgfshapeinnerxsep}
   \advance\pgf@xa\pgf@xc
   \pgf@ya=.5\ht\pgfnodeparttextbox
   \advance\pgf@ya.5\dp\pgfnodeparttextbox
   \pgfmathsetlength\pgf@yc{\pgfshapeinnerysep}
   \advance\pgf@ya\pgf@yc
   \typeout{**** TEST corrected text box (x,y) =
                           (\the\pgf@xa,\the\pgf@ya) }
   \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
   \pgfpathlineto{\pgfpoint{\pgf@xa}{-\pgf@ya}}
   \pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@ya}}
   \pgfpathlineto{\pgfpoint{-\pgf@xa}{\pgf@ya}}
   \pgfpathclose
}
\endinput
%%
%% End of file `makeshape.sty'.