Skip to content

Commit

Permalink
allow name prefix/suffix for pic angle
Browse files Browse the repository at this point in the history
Signed-off-by: Qrrbrbirlbel <qrrbrbirlbel+github@gmail.com>
  • Loading branch information
Qrrbrbirlbel committed Oct 28, 2024
1 parent 6e970a1 commit 699d7ac
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
2 changes: 2 additions & 0 deletions doc/generic/pgf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Resolve missing `gnuplot` plots in manual #1238
- Treat varargs for `min` and `max` in `luamath` pgf-tikz/pgfplots#492 #1359
- Fixed support for the `\tikz` command in the `dvisvgm4ht` driver for TeX4ht
- Supprt of `name prefix`/`name suffix` for pics `angle` and `right angle` (allows nesting it in other pics),
side-effect: any coordinates are now possiblenot just coordinates/nodes #1363

### Changed

Expand Down
4 changes: 0 additions & 4 deletions doc/generic/pgf/pgfmanual-en-library-angles.tex
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ \section{Angle Library}
\end{codeexample}
\end{key}

The three points \meta{A}, \meta{B}, and \meta{C} \emph{must} be the names
of nodes or coordinates; you cannot use direct coordinates like ``|(1,1)|''
here.

You can leave out the three points, in this case the text |A--B--C| is
used; so in the above examples we could just have written |{angle}| in the
first pic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@
}%

\def\tikz@lib@angle@background#1--#2--#3\pgf@stop{%
\path [name prefix ..] [pic actions, draw=none] (#2.center)
\path [name prefix ..] [pic actions, draw=none] (#2)
-- ++(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)
arc [start angle=\tikz@start@angle@temp, end
angle=\tikz@end@angle@temp, radius=\tikz@lib@angle@rad pt] -- cycle;
}%

\def\tikz@lib@angle@foreground#1--#2--#3\pgf@stop{%
\path [name prefix ..] [pic actions, fill=none, shade=none]
([shift={(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)}]#2.center)
([shift={(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)}]#2)
arc [start angle=\tikz@start@angle@temp, end
angle=\tikz@end@angle@temp, radius=\tikz@lib@angle@rad pt];
\ifx\tikzpictext\relax\else%
\def\pgf@temp{\node()[name prefix
..,at={([shift={({.5*\tikz@start@angle@temp+.5*\tikz@end@angle@temp}:\pgfkeysvalueof{/tikz/angle
eccentricity}*\tikz@lib@angle@rad pt)}]#2.center)}]}
eccentricity}*\tikz@lib@angle@rad pt)}]#2)}]}
\expandafter\pgf@temp\expandafter[\tikzpictextoptions]{\tikzpictext};%
\fi
}%

\def\tikz@lib@rightangle@background#1--#2--#3\pgf@stop{%
\path [name prefix ..] [pic actions, draw=none] (#2.center)
\path [name prefix ..] [pic actions, draw=none] (#2)
-- ++(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)
-- ++(\tikz@end@angle@temp:\tikz@lib@angle@rad pt)
-- ++(\tikz@start@angle@temp:-\tikz@lib@angle@rad pt)
Expand All @@ -59,41 +59,44 @@

\def\tikz@lib@rightangle@foreground#1--#2--#3\pgf@stop{%
\path [name prefix ..] [pic actions, fill=none, shade=none]
([shift={(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)}]#2.center)
([shift={(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)}]#2)
-- ++(\tikz@end@angle@temp:\tikz@lib@angle@rad pt)
-- ++(\tikz@start@angle@temp:-\tikz@lib@angle@rad pt);
\ifx\tikzpictext\relax\else%
\def\pgf@temp{\node()[name prefix
..,at={([shift={({.5*\tikz@start@angle@temp+.5*\tikz@end@angle@temp}:\pgfkeysvalueof{/tikz/angle
eccentricity}*1.4142136*\tikz@lib@angle@rad pt)}]#2.center)}]}
eccentricity}*1.4142136*\tikz@lib@angle@rad pt)}]#2)}]}
\expandafter\pgf@temp\expandafter[\tikzpictextoptions]{\tikzpictext};%
\fi
}%

\def\tikz@lib@angle@parse#1--#2--#3\pgf@stop{%
% Compute radius:
\pgfmathsetmacro\tikz@lib@angle@rad{\pgfkeysvalueof{/tikz/angle radius}}
\ifdim\tikz@lib@angle@rad pt>0pt\else\def\tikz@lib@angle@rad{12}\fi%
\pgfmathsetmacro\tikz@lib@angle@rad{\pgfkeysvalueof{/tikz/angle radius}}%
\ifdim\tikz@lib@angle@rad pt>0pt\else\def\tikz@lib@angle@rad{12}\fi
% Compute first coordinate:
\pgf@process{\pgfpointanchor{#2}{center}}%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgfpointanchor{#1}{center}}%
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgf@process{\pgfpointanchor{#3}{center}}%
\pgf@xc=\pgf@x%
\pgf@yc=\pgf@y%
\advance\pgf@xb by-\pgf@xa%
\advance\pgf@yb by-\pgf@ya%
\advance\pgf@xc by-\pgf@xa%
\advance\pgf@yc by-\pgf@ya%
\pgfmathsetmacro{\tikz@start@angle@temp}{atan2(\the\pgf@yb,\the\pgf@xb)}
\pgfmathsetmacro{\tikz@end@angle@temp}{atan2(\the\pgf@yc,\the\pgf@xc)}
\ifdim\tikz@end@angle@temp pt<\tikz@start@angle@temp pt%
\pgfmathsetmacro{\tikz@start@angle@temp}{\tikz@start@angle@temp-360}%
\fi%
}%
\tikz@scan@@absolute\pgf@process(#2)%
\pgf@xa=\pgf@x
\pgf@ya=\pgf@y
\tikz@scan@@absolute\pgf@process(#1)%
\pgf@xb=\pgf@x
\pgf@yb=\pgf@y
\tikz@scan@@absolute\pgf@process(#3)%
\pgf@xc=\pgf@x
\pgf@yc=\pgf@y
\advance\pgf@xb by-\pgf@xa
\advance\pgf@yb by-\pgf@ya
\advance\pgf@xc by-\pgf@xa
\advance\pgf@yc by-\pgf@ya
\pgfmathatantwo@{\pgf@sys@tonumber\pgf@yb}{\pgf@sys@tonumber\pgf@xb}%
\let\tikz@start@angle@temp\pgfmathresult
\pgfmathatantwo@{\pgf@sys@tonumber\pgf@yc}{\pgf@sys@tonumber\pgf@xc}%
\let\tikz@end@angle@temp\pgfmathresult
\ifdim\tikz@end@angle@temp pt<\tikz@start@angle@temp pt
\pgfmathsubtract@{\tikz@start@angle@temp}{360}%
\let\tikz@start@angle@temp\pgfmathresult
\fi
}



Expand Down

0 comments on commit 699d7ac

Please sign in to comment.