| 1 |
%% |
| 2 |
%% This is file `makeshape.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% makeshape.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% Copyright (C) 2013 by Adrian P Robson |
| 10 |
%% [email protected] |
| 11 |
%% |
| 12 |
%% This work may be distributed and/or modified under the |
| 13 |
%% conditions of the LaTeX Project Public License, either |
| 14 |
%% version 1.3c of this license or (at your option) any later |
| 15 |
%% version. The latest version of this license is in |
| 16 |
%% http://www.latex-project.org/lppl.txt |
| 17 |
%% |
| 18 |
%% This work has the LPPL maintenance status `maintained'. |
| 19 |
%% The Current Maintainer of this work is Adrian Robson. |
| 20 |
%% |
| 21 |
%% This work consists of the files makeshape.ins |
| 22 |
%% makeshape.dtx and |
| 23 |
%% ontesting.dtx |
| 24 |
%% and the derived files makeshape.sty |
| 25 |
%% makeshape.pdf |
| 26 |
%% sampleshape.tex |
| 27 |
%% ontesting.pdf |
| 28 |
%% testsample.tex and |
| 29 |
%% testsample.pdf |
| 30 |
%% |
| 31 |
\NeedsTeXFormat{LaTeX2e}[2011/06/27] |
| 32 |
\ProvidesPackage{makeshape} |
| 33 |
[2013/01/25 2.1 Making custom shapes for PGF/TikZ] |
| 34 |
\RequirePackage{tikz} |
| 35 |
\usepgflibrary{intersections} |
| 36 |
\def\setpaths#1#2{ |
| 37 |
\savedmacro\ctbnex{ |
| 38 |
\pgf@x=.5\wd\pgfnodeparttextbox |
| 39 |
\pgfmathsetlength\pgf@xa{\pgfshapeinnerxsep} |
| 40 |
\advance\pgf@x\pgf@xa |
| 41 |
\edef\temp@x{\the\pgf@x} |
| 42 |
\let\ctbnex\temp@x |
| 43 |
} |
| 44 |
\savedmacro\ctbney{ |
| 45 |
\pgf@y=.5\ht\pgfnodeparttextbox |
| 46 |
\advance\[email protected]\dp\pgfnodeparttextbox |
| 47 |
\pgfmathsetlength\pgf@ya{\pgfshapeinnerysep} |
| 48 |
\advance\pgf@y\pgf@ya |
| 49 |
\edef\temp@y{\the\pgf@y} |
| 50 |
\let\ctbney\temp@y |
| 51 |
} |
| 52 |
\savedmacro\pgfshapeouterxsep{ |
| 53 |
\pgfkeysgetvalue{/pgf/outer xsep}{\temp@sep} |
| 54 |
\let\pgfshapeouterxsep\temp@sep |
| 55 |
} |
| 56 |
\savedmacro\pgfshapeouterysep{ |
| 57 |
\pgfkeysgetvalue{/pgf/outer ysep}{\temp@sep} |
| 58 |
\let\pgfshapeouterysep\temp@sep |
| 59 |
} |
| 60 |
\savedmacro{\pgfshapeminwidth}{ |
| 61 |
\pgfkeysgetvalue{/pgf/minimum width}{\temp@wd} |
| 62 |
\let\pgfshapeminwidth\temp@wd |
| 63 |
} |
| 64 |
\savedmacro{\pgfshapeminheight}{ |
| 65 |
\pgfkeysgetvalue{/pgf/minimum height}{\temp@ht} |
| 66 |
\let\pgfshapeminheight\temp@ht |
| 67 |
} |
| 68 |
\savedanchor{\centre}{ |
| 69 |
\pgfpointorigin |
| 70 |
} |
| 71 |
\savedanchor{\text}{ |
| 72 |
\pgf@y=-0.5\ht\pgfnodeparttextbox |
| 73 |
\advance\pgf@y by 0.5\dp\pgfnodeparttextbox |
| 74 |
\pgf@x=-0.5\wd\pgfnodeparttextbox |
| 75 |
} |
| 76 |
\savedanchor{\boundbox@ne}{ |
| 77 |
\pgfusepath{} |
| 78 |
#1 |
| 79 |
\pgf@xb=\pgf@pathmaxx |
| 80 |
\pgf@yb=\pgf@pathmaxy |
| 81 |
\pgf@xc=\pgf@pathminx |
| 82 |
\pgf@yc=\pgf@pathminy |
| 83 |
\pgfusepath{} |
| 84 |
\ifdim\pgf@xb<0pt \pgf@xb=-\pgf@xb \fi |
| 85 |
\ifdim\pgf@xc<0pt \pgf@xc=-\pgf@xc \fi |
| 86 |
\ifdim\pgf@xb<\pgf@xc |
| 87 |
\pgf@x=\pgf@xc |
| 88 |
\else |
| 89 |
\pgf@x=\pgf@xb |
| 90 |
\fi |
| 91 |
\ifdim\pgf@yb<0pt \pgf@yb=-\pgf@yb \fi |
| 92 |
\ifdim\pgf@yc<0pt \pgf@yc=-\pgf@yc \fi |
| 93 |
\ifdim\pgf@yb<\pgf@yc |
| 94 |
\pgf@y=\pgf@yc |
| 95 |
\else |
| 96 |
\pgf@y=\pgf@yb |
| 97 |
\fi |
| 98 |
} |
| 99 |
\anchor{center}{\centre} |
| 100 |
\anchor{text}{\text} |
| 101 |
\anchorborder{ |
| 102 |
\edef\targpointx{\the\pgf@x} |
| 103 |
\edef\targpointy{\the\pgf@y} |
| 104 |
\pgf@relevantforpicturesizefalse |
| 105 |
\pgftransformreset |
| 106 |
\boundbox@ne |
| 107 |
\pgf@xa=\pgf@x |
| 108 |
\pgf@ya=\pgf@y |
| 109 |
\pgfpointborderrectangle{\pgfpoint{\targpointx}{\targpointy}} |
| 110 |
{\pgfpoint{\pgf@xa}{\pgf@ya}} |
| 111 |
\edef\corrx{\the\pgf@x} |
| 112 |
\edef\corry{\the\pgf@y} |
| 113 |
\pgfintersectionofpaths { |
| 114 |
#1 |
| 115 |
}{ |
| 116 |
\pgfpathmoveto{\pgfpoint{0}{0}} |
| 117 |
\pgfpathlineto{\pgfpoint{\corrx}{\corry}} |
| 118 |
} |
| 119 |
\pgfpointintersectionsolution{1} |
| 120 |
} |
| 121 |
\backgroundpath{ |
| 122 |
#2 |
| 123 |
} |
| 124 |
} |
| 125 |
\newdimen\crct@dim |
| 126 |
\def\mincorrect#1#2{ |
| 127 |
\pgfmathsetlength\crct@dim{#2} |
| 128 |
\pgfmathsetlength\crct@dim{0.5\crct@dim} |
| 129 |
\ifdim#1<\crct@dim |
| 130 |
#1=\crct@dim |
| 131 |
\fi |
| 132 |
} |
| 133 |
\def\path@textbox{ |
| 134 |
\pgf@xa=.5\wd\pgfnodeparttextbox |
| 135 |
\pgf@ya=.5\ht\pgfnodeparttextbox |
| 136 |
\advance\[email protected]\dp\pgfnodeparttextbox |
| 137 |
\typeout{**** TEST text box (x,y) = (\the\pgf@xa,\the\pgf@ya) } |
| 138 |
\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} |
| 139 |
\pgfpathlineto{\pgfpoint{\pgf@xa}{-\pgf@ya}} |
| 140 |
\pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@ya}} |
| 141 |
\pgfpathlineto{\pgfpoint{-\pgf@xa}{\pgf@ya}} |
| 142 |
\pgfpathclose |
| 143 |
} |
| 144 |
\def\path@ctextbox{ |
| 145 |
\pgf@xa=.5\wd\pgfnodeparttextbox |
| 146 |
\pgfmathsetlength\pgf@xc{\pgfshapeinnerxsep} |
| 147 |
\advance\pgf@xa\pgf@xc |
| 148 |
\pgf@ya=.5\ht\pgfnodeparttextbox |
| 149 |
\advance\[email protected]\dp\pgfnodeparttextbox |
| 150 |
\pgfmathsetlength\pgf@yc{\pgfshapeinnerysep} |
| 151 |
\advance\pgf@ya\pgf@yc |
| 152 |
\typeout{**** TEST corrected text box (x,y) = |
| 153 |
(\the\pgf@xa,\the\pgf@ya) } |
| 154 |
\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} |
| 155 |
\pgfpathlineto{\pgfpoint{\pgf@xa}{-\pgf@ya}} |
| 156 |
\pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@ya}} |
| 157 |
\pgfpathlineto{\pgfpoint{-\pgf@xa}{\pgf@ya}} |
| 158 |
\pgfpathclose |
| 159 |
} |
| 160 |
\endinput |
| 161 |
%% |
| 162 |
%% End of file `makeshape.sty'. |