| 1 |
%% xyrotate.tex from $Id: xyrotate.doc,v 3.8 2011/03/14 20:14:00 krisrose Exp $ |
| 2 |
%% |
| 3 |
%% Xy-pic ``Rotate and Scale extension'' option. |
| 4 |
%% Copyright (c) 1993-1996 Ross Moore <[email protected]> |
| 5 |
%% |
| 6 |
%% This file is part of the Xy-pic package for graphs and diagrams in TeX. |
| 7 |
%% See the companion README and INSTALL files for further information. |
| 8 |
%% Copyright (c) 1991-2011 Kristoffer H. Rose <[email protected]> |
| 9 |
%% |
| 10 |
%% The Xy-pic package is free software; you can redistribute it and/or modify |
| 11 |
%% it under the terms of the GNU General Public License as published by the |
| 12 |
%% Free Software Foundation; either version 2 of the License, or (at your |
| 13 |
%% option) any later version. |
| 14 |
%% |
| 15 |
%% The Xy-pic package is distributed in the hope that it will be useful, but |
| 16 |
%% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 17 |
%% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 18 |
%% for more details. |
| 19 |
%% |
| 20 |
%% You should have received a copy of the GNU General Public License along |
| 21 |
%% with this package; if not, see http://www.gnu.org/licenses/. |
| 22 |
%% |
| 23 |
\ifx\xyloaded\undefined \input xy \fi |
| 24 |
\xyprovide{rotate}{Rotate and Scale extension}{\stripRCS$Revision: 3.8 $}% |
| 25 |
{Ross Moore}{[email protected]}% |
| 26 |
{Mathematics Department, Macquarie University, NSW~2109, Australia} |
| 27 |
\xydef@\xyundefinedRotate@#1#2@@{% |
| 28 |
\xywarning@{The #1 #2 effect is not implemented with the current driver.}}% |
| 29 |
\xydef@\NoResizing{\xyNoResizing@} |
| 30 |
\xydef@\UseResizing{\xyUseResizing@} |
| 31 |
\xydef@\xyNoResizing@{% |
| 32 |
\global\let\origxyrescale@=\xyrescale@ |
| 33 |
\global\let\origxyrotSizeMod@=\xyrotateSizeMod@ |
| 34 |
\global\let\xyNoResizing@=\xyNoResizing@@ |
| 35 |
\global\let\xyUseResizing@=\xyUseResizing@@ |
| 36 |
\xyNoResizing@@ } |
| 37 |
\xydef@\xyNoResizing@@{% |
| 38 |
\global\let\xyrescale@=\xyignorescale@ |
| 39 |
\global\let\xyrotateSizeMod@=\xyignoreSizeMod@ |
| 40 |
} |
| 41 |
\xylet@\xyUseResizing@=\relax |
| 42 |
\xydef@\xyUseResizing@@{% |
| 43 |
\global\let\xyrescale@=\origxyrescale@ |
| 44 |
\global\let\xyrotateSizeMod@=\origxyrotSizeMod@ |
| 45 |
} |
| 46 |
\xydefcsname@{shape [@...]}#1{\xyrotatechar@#1@@}% |
| 47 |
\xydefcsname@{shape [<...]}#1{\xyshearchar@{#1}@@}% |
| 48 |
\xydefcsname@{shape [*...]}#1{\xyscalechar@{#1}@@}% |
| 49 |
\xydefcsname@{shape [left]}{\xyshape@left@} |
| 50 |
\xydefcsname@{shape [right]}{\xyshape@right@} |
| 51 |
\xydefcsname@{shape [flip]}{\xyshape@flip@} |
| 52 |
\xydefcsname@{shape [halfsize]}{\xyshape@halfsize@} |
| 53 |
\xydefcsname@{shape [dblsize]}{\xyshape@dblsize@} |
| 54 |
\xydefcsname@{shape [vflip]}{\xyshape@vflip@} |
| 55 |
\xydefcsname@{shape [hflip]}{\xyshape@hflip@} |
| 56 |
\xydef@\preXYtransform@{} |
| 57 |
\xydef@\postXYtransform@{} |
| 58 |
\xywarnifdefined\preXYtransform@@ |
| 59 |
\xywarnifdefined\postXYtransform@@ |
| 60 |
\gdef\preXYtransform@@{} |
| 61 |
\gdef\postXYtransform@@{} |
| 62 |
\xydef@\xy@transform@{} |
| 63 |
\xydef@\preShape@@{} |
| 64 |
\xydef@\postShape@@{} |
| 65 |
\xydef@\modXYtransform@{% |
| 66 |
\ifx\xy@transform@\empty |
| 67 |
\transformDrop@\transformConnect@\resetTransform@\fi |
| 68 |
\DN@##1{\expandafter\def\expandafter\tmp@\expandafter{##1}}% |
| 69 |
\expandafter\next@\expandafter{\preShape@@}% |
| 70 |
\DN@##1{\expandafter\gdef\expandafter\preXYtransform@@\expandafter{% |
| 71 |
\tmp@ ##1}}\expandafter\next@\expandafter{\preXYtransform@@}% |
| 72 |
\DN@##1{\expandafter\def\expandafter\tmp@\expandafter{##1}}% |
| 73 |
\expandafter\next@\expandafter{\postShape@@}% |
| 74 |
\DN@##1{\expandafter\gdef\expandafter\postXYtransform@@\expandafter{% |
| 75 |
\postXYtransform@@ ##1}}\expandafter\next@\expandafter{\tmp@}}% |
| 76 |
\xydef@\transformDrop@{\let\xy@transform@=\relax |
| 77 |
\expandafter\def\expandafter\Drop@@\expandafter{% |
| 78 |
\expandafter\preXYtransform@\Drop@@\postXYtransform@}} |
| 79 |
\xydef@\transformConnect@{\let\xy@transform@=\relax |
| 80 |
\expandafter\def\expandafter\Connect@@\expandafter{% |
| 81 |
\expandafter\preXYtransform@\Connect@@\postXYtransform@}} |
| 82 |
\xydef@\resetTransform@{\gdef\preXYtransform@@{}\gdef\postXYtransform@@{}} |
| 83 |
\xydef@\xynametransform@#1{% |
| 84 |
\DN@{\expandafter\gdef\expandafter#1\expandafter{\the\toks@}}\next@ } |
| 85 |
\xydef@\xyscalechar@#1@@{\xyscalechars@#1,#1,@@} |
| 86 |
\xydef@\xyscalechars@#1,#2,#3@@{% |
| 87 |
\DN@{\xyrescale@(#1,#2)}% |
| 88 |
\dimen@=#1\p@ |
| 89 |
\ifdim\dimen@>\z@ \else \ifdim\dimen@<\z@ \else |
| 90 |
\DN@{\xywarning@{invalid scaling factors #1, #2}}% |
| 91 |
\fi\fi \dimen@=#2\p@ |
| 92 |
\ifdim\dimen@>\z@ \else \ifdim\dimen@<\z@ \else |
| 93 |
\DN@{\xywarning@{invalid scaling factors #1, #2 }}% |
| 94 |
\fi\fi \next@ } |
| 95 |
\xydef@\xyrescale@(#1,#2){% |
| 96 |
\setboxz@h{\xyscale@@{#1}{#2}% |
| 97 |
\dimen@=\ifx-#1\R@c\advance\dimen@-\R@c \dimen@=-\dimen@ |
| 98 |
\else#1\L@c \advance\dimen@-\L@c\fi |
| 99 |
\kern\dimen@\boxz@\kern-\dimen@}% |
| 100 |
\R@c=\if-#1\L@c\else#1\R@c\fi |
| 101 |
\L@c=\if-#1\R@c\else#1\L@c\fi |
| 102 |
\U@c=\if-#2\D@c\else#2\U@c\fi |
| 103 |
\D@c=\if-#2\U@c\else#2\D@c\fi } |
| 104 |
\xydef@\xyignorescale@(#1,#2){\xywarning@{Ignoring rescale: #1,#2}% |
| 105 |
\setboxz@h{\xyscale@@{#1}{#2}\boxz@}}% |
| 106 |
\xydef@\xyshape@halfsize@{\xyrescale@(.5,.5)} |
| 107 |
\xydef@\xyshape@dblsize@{\xyrescale@(2,2)} |
| 108 |
\xydef@\xyshape@flip@{\xyrescale@(-1,-1)} |
| 109 |
\xydef@\xyshape@vflip@{\xyrescale@(1,-1)} |
| 110 |
\xydef@\xyshape@hflip@{\xyrescale@(-1,1)} |
| 111 |
\xydef@\xyrotatechar@{\bgroup |
| 112 |
\afterDIRECTIONorEMPTY{\xyrotateSizeMod@}{\xyFN@\xySpecialRotate@i}} |
| 113 |
\xydef@\xySpecialRotate@i{% |
| 114 |
\ifx \space@\next \expandafter\DN@\space{\xyFN@\xySpecialRotate@i}% |
| 115 |
\else\ifx @\next \let\next@=\xyrotateSizeMod@ |
| 116 |
\else\addEQ@\ifx \next |
| 117 |
\addEQ@\DN@##1@@{% |
| 118 |
\expandafter\xynametransform@\csname shape [##1]\endcsname\egroup}% |
| 119 |
\else\ifx !\next \DN@!{\egroup\getSpecialRotate@}% |
| 120 |
\else\ifx *\next \DN@*@@{\egroup\transformDrop@}% |
| 121 |
\else \DN@{\xySpecialRotate@@}% |
| 122 |
\fi\fi\fi\fi\fi \next@ } |
| 123 |
\xydef@\getSpecialRotate@{\doSpecialRotate@@} |
| 124 |
\xydef@\xyRotate@#1{\xyundefinedRotate@{rotate}{#1}@@} |
| 125 |
\xydef@\xySpecialRotate@#1@@{\xyundefinedRotate@{rotate}{#1}@@\egroup} |
| 126 |
\xydef@\doSpecialRotate@#1@@{\xyundefinedRotate@{special rotate}{#1}@@} |
| 127 |
\xydef@\xyscale@#1#2{\xyundefinedRotate@{scale}{#1,#2}@@} |
| 128 |
\xydef@\UnloadRotate@#1{% |
| 129 |
\ifx#1\relax\else\xyunload@{rotation extension}\fi |
| 130 |
\let\xyRotate@@=\xyRotate@ |
| 131 |
\let\xySpecialRotate@@=\xySpecialRotate@ |
| 132 |
\let\doSpecialRotate@@=\doSpecialRotate@ |
| 133 |
\let\xyscale@@=\xyscale@ } |
| 134 |
\UnloadRotate@\relax |
| 135 |
\xyaddunsupport{rotate}{\UnloadRotate@\relax} |
| 136 |
\xydef@\xyrotateSizeMod@ @@{% |
| 137 |
\L@p=\L@c \R@p=\R@c \U@p=\U@c \D@p=\D@c |
| 138 |
\ifdim\cosDirection\p@>\z@ |
| 139 |
\R@c=\cosDirection\R@p \L@c=\cosDirection\L@p |
| 140 |
\U@c=\cosDirection\U@p \D@c=\cosDirection\D@p |
| 141 |
\else |
| 142 |
\R@c=\cosDirection\L@p \L@c=\cosDirection\R@p |
| 143 |
\U@c=\cosDirection\D@p \D@c=\cosDirection\U@p |
| 144 |
\fi |
| 145 |
\advance\L@c \if-\sinDirection\D@p\else\sinDirection\U@p\fi |
| 146 |
\advance\R@c \if-\sinDirection\U@p\else\sinDirection\D@p\fi |
| 147 |
\advance\U@c \if-\sinDirection\L@p\else\sinDirection\R@p\fi |
| 148 |
\advance\D@c \if-\sinDirection\R@p\else\sinDirection\L@p\fi |
| 149 |
\dimen@ii=\L@c \advance\dimen@ii-\L@p |
| 150 |
\edef\tmp@{\egroup \L@c=\the\L@c \R@c=\the\R@c \U@c=\the\U@c \D@c=\the\D@c |
| 151 |
\dimen@ii=\the\dimen@ii \noexpand\setboxz@h\bgroup |
| 152 |
\noexpand\xyRotate@@{\the\Direction}}\tmp@ |
| 153 |
\xydropRotated@ } |
| 154 |
\xydef@\xydropRotated@@{% |
| 155 |
\kern\dimen@ii \boxz@ \kern-\dimen@ii \modXYtransform@ \egroup } |
| 156 |
\xylet@\xydropRotated@=\xydropRotated@@ |
| 157 |
\xydef@\xyignoreSizeMod@ @@{\xywarning@{Ignoring rotation}} |
| 158 |
\xydef@\xyshape@left@{\xyrotatechar@ v(0,1)@@} |
| 159 |
\xydef@\xyshape@right@{\xyrotatechar@ v(0,-1)@@} |
| 160 |
\xydef@\xyshearchar@{\xyundefinedRotate@{shearing}} |
| 161 |
\xyendinput |