Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sloped/transform shape with non-identity transformation #1371

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions doc/generic/pgf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed

- Typo in animations `end on` key #1273
- `sloped` should consider the current transformation #1058
- Output bounding box adjustment in pgfsys-dvisvgm.def #1275
- Fix shadings under LuaMetaTeX
- Resolve missing `gnuplot` plots in manual #1238
Expand All @@ -40,6 +41,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Matthias Hetzenberger
- Qrrbrbirlbel
- quark67
- thinbold
- Rocky Zhang (@rockyzhz)
- Romano Giannetti (@rmano)
- Yukai Chou (@muzimuzhi)
Expand Down
142 changes: 65 additions & 77 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,45 +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{%
\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%
\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 @@ -510,32 +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{%
\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%
\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 @@ -553,40 +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{%
\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%
\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
Loading