Skip to content

Commit

Permalink
Refactored \pgftransform…attime
Browse files Browse the repository at this point in the history
Signed-off-by: Qrrbrbirlbel <[email protected]>

Signoff

Signed-off-by: Qrrbrbirlbel <[email protected]>
  • Loading branch information
Qrrbrbirlbel committed Oct 30, 2023
1 parent d502bb2 commit d241efe
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 110 deletions.
1 change: 0 additions & 1 deletion doc/generic/pgf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Andreas Deininger
- Matthias Hetzenberger
- muzimuzhi
- Qrrbrbirlbel
- quark67
- thinbold
Expand Down
174 changes: 65 additions & 109 deletions tex/generic/pgf/basiclayer/pgfcoretransformations.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,45 @@
\newif\ifpgfallowupsidedownattime
\newif\ifpgfresetnontranslationattime

% Common code for \pgftransformlineatttime,
% \pgftransformarcaxesattime and \pgftransformcurveattime
%
% #1 = \pgfpoint...attime
% #2 = Setup for tangent in \pgf@x and \pgf@y for \ifslopedattime

\def\pgftransform@commonattime#1#2{%
\let\pgf@tempaa\pgf@pt@aa
\let\pgf@tempab\pgf@pt@ab
\let\pgf@tempba\pgf@pt@ba
\let\pgf@tempbb\pgf@pt@bb
#1%
\pgftransformshift{}%
\ifpgfresetnontranslationattime
\pgftransformresetnontranslations
\fi
\ifpgfslopedattime
#2%
\ifpgfresetnontranslationattime
\begingroup
\pgfsettransformentries{\pgf@tempaa}{\pgf@tempab}{\pgf@tempba}{\pgf@tempbb}{0pt}{0pt}%
\pgf@process{\pgf@pos@transform{\pgf@x}{\pgf@y}}%
\endgroup
\fi
\pgfpointnormalised{}% x/y = normalised vector
\ifpgfallowupsidedownattime
\else
\ifdim\pgf@x<0pt
\pgf@x=-\pgf@x
\pgf@y=-\pgf@y
\fi
\fi
\pgf@ya=-\pgf@y
\pgftransformcm
{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}%
{\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}%
\fi
}


% Transform to the coordinate system of a point on a line
%
Expand All @@ -455,57 +494,23 @@
% Example:
%
% {
% \pgftransformlineattime{.5}{\pgfxy(0,0)}{\pgfxy(3,2)}
% \pgftransformlineattime{.5}{\pgfpointxy{0}{0}}{\pgfpointxy{3}{2}}
% \pgftext{Hi!}
% }
%
% {
% \pgftransformlineattime{.75}{\pgfxy(0,0)}{\pgfxy(3,2)}
% \pgftransformlineattime{.75}{\pgfpointxy{0}{0}}{\pgfpointxy{3}{2}}
% \pgftransformresetnontranslations
% \pgftext{Hi!}
% }
%
\def\pgftransformlineattime#1#2#3{%
\let\pgf@tempaa\pgf@pt@aa
\let\pgf@tempab\pgf@pt@ab
\let\pgf@tempba\pgf@pt@ba
\let\pgf@tempbb\pgf@pt@bb
\pgf@process{#2}%
\pgf@xb=\pgf@x% xb/yb = start point
\pgf@yb=\pgf@y%
\pgf@process{#3}%
\pgf@xc=\pgf@x% xc/yc = end point
\pgf@yc=\pgf@y%
\pgftransformshift{\pgfpointlineattime{#1}{\pgfqpoint{\pgf@xb}{\pgf@yb}}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}%
\ifpgfresetnontranslationattime%
\pgftransformresetnontranslations%
\fi%
\ifpgfslopedattime%
\advance\pgf@xc by-\pgf@xb%
\advance\pgf@yc by-\pgf@yb%
\ifpgfresetnontranslationattime
\begingroup
\pgfsettransformentries{\pgf@tempaa}{\pgf@tempab}{\pgf@tempba}{\pgf@tempbb}{0pt}{0pt}%
\pgf@pos@transform{\pgf@xc}{\pgf@yc}%
\xdef\pgf@marshal{\pgf@xc=\the\pgf@xc\pgf@yc=\the\pgf@yc}%
\endgroup
\pgf@marshal
\fi
\ifpgfallowupsidedownattime%
\else%
\ifdim\pgf@xc<0pt%
\pgf@xc=-\pgf@xc%
\pgf@yc=-\pgf@yc%
\fi%
\fi%
\pgf@x=\pgf@xc%
\pgf@y=\pgf@yc%
\pgfpointnormalised{}% x/y = normalised vector
\pgf@ya=-\pgf@y%
\pgftransformcm%
{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}%
{\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}%
\fi%
\pgftransform@commonattime{%
\pgfpointlineattime{#1}{#2}{#3}%
}{% \pgfpointlineattime provides tangent in xa/ya
\pgf@x=\pgf@xa
\pgf@y=\pgf@ya
}%
}


Expand All @@ -522,42 +527,17 @@
% Example:
%
% {
% \pgftransformlineattime{.5}{\pgfpoint{1cm}{1cm}}{\pgfpoint{1cm}{0cm}}{\pgfpoint{0cm}{1cm}}{30}{40}
% \pgftransformarcaxesattime{.5}{\pgfpoint{1cm}{1cm}}{\pgfpoint{1cm}{0cm}}{\pgfpoint{0cm}{1cm}}{30}{40}
% \pgftext{Hi!}
% }

\def\pgftransformarcaxesattime#1#2#3#4#5#6{%
\let\pgf@tempaa\pgf@pt@aa
\let\pgf@tempab\pgf@pt@ab
\let\pgf@tempba\pgf@pt@ba
\let\pgf@tempbb\pgf@pt@bb
\pgfpointarcaxesattime{#1}{#2}{#3}{#4}{#5}{#6}%
\pgftransformshift{\pgfqpoint{\pgf@x}{\pgf@y}}%
\ifpgfresetnontranslationattime%
\pgftransformresetnontranslations%
\fi%
\ifpgfslopedattime%
\pgf@x=\pgf@xa%
\pgf@y=\pgf@ya%
\ifpgfresetnontranslationattime
\begingroup
\pgfsettransformentries{\pgf@tempaa}{\pgf@tempab}{\pgf@tempba}{\pgf@tempbb}{0pt}{0pt}%
\pgf@process{\pgf@pos@transform{\pgf@x}{\pgf@y}}%
\endgroup
\fi
\pgf@process{\pgfpointnormalised{}}%
\ifpgfallowupsidedownattime%
\else%
\ifdim\pgf@x<0pt%
\pgf@x=-\pgf@x%
\pgf@y=-\pgf@y%
\fi%
\fi%
\pgf@ya=-\pgf@y%
\pgftransformcm%
{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}%
{\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}%
\fi%
\pgftransform@commonattime{%
\pgfpointarcaxesattime{#1}{#2}{#3}{#4}{#5}{#6}%
}{% \pgfpointarcaxestime provides tangent in xa/ya
\pgf@x=\pgf@xa
\pgf@y=\pgf@ya
}%
}


Expand All @@ -575,50 +555,26 @@
% Example:
%
% {
% \pgftransformcurveattime{.5}{\pgfxy(0,0)}{\pgfxy(3,2)}
% \pgftransformcurveattime{.5}{\pgfpointxy{0}{0}}{\pgfpointxy{1}{1}}{\pgfpointxy{2}{2}}{\pgfpointxy{3}{2}}
% \pgftext{Hi!}
% }
%
% {
% \pgftransformcurveattime{.75}{\pgfxy(0,0)}{\pgfxy(3,2)}
% \pgftransformcurveattime{.75}{\pgfpointxy{0}{0}}{\pgfpointxy{1}{1}}{\pgfpointxy{2}{2}}{\pgfpointxy{3}{2}}
% \pgftransformresetnontranslations
% \pgftext{Hi!}
% }
%
\def\pgftransformcurveattime#1#2#3#4#5{%
\let\pgf@tempaa\pgf@pt@aa
\let\pgf@tempab\pgf@pt@ab
\let\pgf@tempba\pgf@pt@ba
\let\pgf@tempbb\pgf@pt@bb
\pgfpointcurveattime{#1}{#2}{#3}{#4}{#5}%
\pgftransformshift{\pgfqpoint{\pgf@x}{\pgf@y}}%
\ifpgfresetnontranslationattime%
\pgftransformresetnontranslations%
\fi%
\ifpgfslopedattime%
\pgf@x=\pgf@xa%
\pgf@y=\pgf@ya%
\advance\pgf@x by-\pgf@xb%
\advance\pgf@y by-\pgf@yb%
\ifpgfresetnontranslationattime
\begingroup
\pgfsettransformentries{\pgf@tempaa}{\pgf@tempab}{\pgf@tempba}{\pgf@tempbb}{0pt}{0pt}%
\pgf@process{\pgf@pos@transform{\pgf@x}{\pgf@y}}%
\endgroup
\fi
\ifpgfallowupsidedownattime%
\else%
\ifdim\pgf@x<0pt%
\pgf@x=-\pgf@x%
\pgf@y=-\pgf@y%
\fi%
\fi%
\pgfpointnormalised{}% x/y = normalised vector
\pgf@ya=-\pgf@y%
\pgftransformcm%
{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}%
{\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}%
\fi%
\pgftransform@commonattime{%
\pgfpointcurveattime{#1}{#2}{#3}{#4}{#5}%
}{% \pgfpoointcurveattime provides tangent xa/ya -- xb/yb
% need to calculate difference for tangent direction
\pgf@x=\pgf@xa
\pgf@y=\pgf@ya
\advance\pgf@x by-\pgf@xb
\advance\pgf@y by-\pgf@yb
}%
}


Expand Down

0 comments on commit d241efe

Please sign in to comment.