%%
%% 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'.
