From 699d7ac468f690f8f9f62c3a58461eb7f4c581b3 Mon Sep 17 00:00:00 2001 From: Qrrbrbirlbel Date: Mon, 28 Oct 2024 18:47:44 +0100 Subject: [PATCH 1/3] allow name prefix/suffix for pic angle Signed-off-by: Qrrbrbirlbel --- doc/generic/pgf/CHANGELOG.md | 2 + .../pgf/pgfmanual-en-library-angles.tex | 4 -- .../tikz/libraries/tikzlibraryangles.code.tex | 57 ++++++++++--------- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/doc/generic/pgf/CHANGELOG.md b/doc/generic/pgf/CHANGELOG.md index 38c2280f7..71a2e57e2 100644 --- a/doc/generic/pgf/CHANGELOG.md +++ b/doc/generic/pgf/CHANGELOG.md @@ -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 diff --git a/doc/generic/pgf/pgfmanual-en-library-angles.tex b/doc/generic/pgf/pgfmanual-en-library-angles.tex index e210cb2d7..ea9eb91c9 100644 --- a/doc/generic/pgf/pgfmanual-en-library-angles.tex +++ b/doc/generic/pgf/pgfmanual-en-library-angles.tex @@ -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. diff --git a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex index 2d6abbd2e..c1c2f2fcf 100644 --- a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex +++ b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex @@ -30,7 +30,7 @@ }% \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; @@ -38,19 +38,19 @@ \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) @@ -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 +} From e7e1bf8a1748928e4e66f9a17929b149b41515be Mon Sep 17 00:00:00 2001 From: Qrrbrbirlbel Date: Mon, 28 Oct 2024 18:48:45 +0100 Subject: [PATCH 2/3] Update CHANGELOG.md Signed-off-by: Qrrbrbirlbel --- doc/generic/pgf/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/generic/pgf/CHANGELOG.md b/doc/generic/pgf/CHANGELOG.md index 71a2e57e2..20c29ab90 100644 --- a/doc/generic/pgf/CHANGELOG.md +++ b/doc/generic/pgf/CHANGELOG.md @@ -20,7 +20,7 @@ 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), +- Support 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 From 6bd4d90b6ebc20207c7b85fcef433f408e5ed210 Mon Sep 17 00:00:00 2001 From: Qrrbrbirlbel Date: Mon, 20 Jan 2025 20:31:46 +0100 Subject: [PATCH 3/3] Update doc/generic/pgf/CHANGELOG.md Co-authored-by: Yukai Chou --- doc/generic/pgf/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/generic/pgf/CHANGELOG.md b/doc/generic/pgf/CHANGELOG.md index 20c29ab90..661c2a9a7 100644 --- a/doc/generic/pgf/CHANGELOG.md +++ b/doc/generic/pgf/CHANGELOG.md @@ -21,7 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - 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 - Support 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 + side-effect: any coordinates are now possibly not just coordinates/nodes #1363 ### Changed