diff options
Diffstat (limited to 'graphics/pgf/contrib/tikz-ext/tex/generic')
18 files changed, 3950 insertions, 0 deletions
diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgfcalendar-ext.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgfcalendar-ext.code.tex new file mode 100644 index 0000000000..90b42a0011 --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgfcalendar-ext.code.tex @@ -0,0 +1,370 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +\pgfqkeys{/pgf/calendar}{ + style/.style={#1}, + yesterday/.value required, + yesterday/.code={% + \begingroup + \pgfutil@tempcnta=\pgfcalendarifdatejulian\relax + \advance\pgfutil@tempcnta by -1\relax + \pgfcalendarjuliantodate{\pgfutil@tempcnta}{\pgfcalendarifdateyear}{\pgfcalendarifdatemonth}{\pgfcalendarifdateday}% + \edef\pgfcalendarifdatejulian{\the\pgfutil@tempcnta}% + \pgfcalendarjuliantoweekday\pgfutil@tempcnta\pgfutil@tempcntb + \edef\pgfcalendarifdateweekday{\the\pgfutil@tempcntb}% + \pgfcalendarjulianyeartoweek\pgfutil@tempcnta\pgfcalendarifdateyear\pgfutil@tempcntb + \edef\pgfcalendarifdateweek{\the\pgfutil@tempcntb}% + \pgfcalendar@launch@ifdate{#1}{% + \def\pgf@cal@temp{\pgfcalendarmatchestrue}% + }{% + \let\pgf@cal@temp\pgfutil@empty + }% + \expandafter + \endgroup\pgf@cal@temp + }, + relative/.code 2 args={% + \begingroup + \pgfutil@tempcnta=\pgfcalendarifdatejulian\relax + \advance\pgfutil@tempcnta by #1\relax + \pgfcalendarjuliantodate{\pgfutil@tempcnta}{\pgfcalendarifdateyear}{\pgfcalendarifdatemonth}{\pgfcalendarifdateday}% + \edef\pgfcalendarifdatejulian{\the\pgfutil@tempcnta}% + \pgfcalendarjuliantoweekday\pgfutil@tempcnta\pgfutil@tempcntb + \edef\pgfcalendarifdateweekday{\the\pgfutil@tempcntb}% + \pgfcalendarjulianyeartoweek\pgfutil@tempcnta\pgfcalendarifdateyear\pgfutil@tempcntb + \edef\pgfcalendarifdateweek{\the\pgfutil@tempcntb}% + \pgfcalendar@launch@ifdate{#2}{% + \def\pgf@cal@temp{\pgfcalendarmatchestrue}% + }{% + \let\pgf@cal@temp\pgfutil@empty + }% + \expandafter + \endgroup\pgf@cal@temp + }, + Jan/.code={\ifnum\pgfcalendarifdatemonth=1 \expandafter\pgfcalendarmatchestrue\fi},Jan/.value forbidden, + Feb/.code={\ifnum\pgfcalendarifdatemonth=2 \expandafter\pgfcalendarmatchestrue\fi},Feb/.value forbidden, + Mar/.code={\ifnum\pgfcalendarifdatemonth=3 \expandafter\pgfcalendarmatchestrue\fi},Mar/.value forbidden, + Apr/.code={\ifnum\pgfcalendarifdatemonth=4 \expandafter\pgfcalendarmatchestrue\fi},Apr/.value forbidden, + May/.code={\ifnum\pgfcalendarifdatemonth=5 \expandafter\pgfcalendarmatchestrue\fi},May/.value forbidden, + Jun/.code={\ifnum\pgfcalendarifdatemonth=6 \expandafter\pgfcalendarmatchestrue\fi},Jun/.value forbidden, + Jul/.code={\ifnum\pgfcalendarifdatemonth=7 \expandafter\pgfcalendarmatchestrue\fi},Jul/.value forbidden, + Aug/.code={\ifnum\pgfcalendarifdatemonth=8 \expandafter\pgfcalendarmatchestrue\fi},Aug/.value forbidden, + Sep/.code={\ifnum\pgfcalendarifdatemonth=9 \expandafter\pgfcalendarmatchestrue\fi},Sep/.value forbidden, + Oct/.code={\ifnum\pgfcalendarifdatemonth=10 \expandafter\pgfcalendarmatchestrue\fi},Oct/.value forbidden, + Nov/.code={\ifnum\pgfcalendarifdatemonth=11 \expandafter\pgfcalendarmatchestrue\fi},Nov/.value forbidden, + Dec/.code={\ifnum\pgfcalendarifdatemonth=12 \expandafter\pgfcalendarmatchestrue\fi},Dec/.value forbidden, + % + leap year/.code={% + \pgfutil@tempcnta=#1\relax + \divide\pgfutil@tempcnta4 + \multiply\pgfutil@tempcnta4 + \ifnum\pgfutil@tempcnta=#1\relax + \divide\pgfutil@tempcnta100 + \multiply\pgfutil@tempcnta100 + \ifnum\pgfutil@tempcnta=#1\relax + \divide\pgfutil@tempcnta400 + \multiply\pgfutil@tempcnta400 + \ifnum\pgfutil@tempcnta=#1\relax + \pgfcalendarmatchestrue + \fi + \else + \pgfcalendarmatchestrue + \fi + \fi}, + leap year/.default=\pgfcalendarifdateyear, + between days/.value required, + between days/.code args={#1and#2}{% + \pgfutil@tempcnta=#1\relax + \ifnum\pgfcalendarifdateday<\pgfutil@tempcnta\else + \pgfutil@tempcnta=#2\relax + \ifnum\pgfcalendarifdateday>\pgfutil@tempcnta\else + \pgfcalendarmatchestrue\fi\fi}, + week of month/.code={% + \pgfutil@tempcnta=#1\relax + \multiply\pgfutil@tempcnta7 + \ifnum\pgfcalendarifdateday>\pgfutil@tempcnta\else + \advance\pgfutil@tempcnta-7 + \ifnum\pgfcalendarifdateday>\pgfutil@tempcnta + \pgfcalendarmatchestrue + \fi + \fi}, + week of month'/.code={% + \pgfcalendar@getlastYMX\pgfcalendarifdateyear\pgfcalendarifdatemonth\pgfutil@tempcnta + \advance\pgfutil@tempcnta1 + \pgfutil@tempcntb=#1\relax + \multiply\pgfutil@tempcntb7 + \advance\pgfutil@tempcnta-\pgfutil@tempcntb + \ifnum\pgfcalendarifdateday<\pgfutil@tempcnta\else + \advance\pgfutil@tempcnta+7 + \ifnum\pgfcalendarifdateday<\pgfutil@tempcnta + \pgfcalendarmatchestrue + \fi + \fi}, + first/.code={\pgfutil@in@:{#1}\ifpgfutil@in@ + \pgfcalendar@ifdate@first{}#1\pgf@stop\else + \pgfcalendar@ifdate@first{}1:#1\pgf@stop\fi}, + last/.code={\pgfutil@in@:{#1}\ifpgfutil@in@ + \pgfcalendar@ifdate@first'#1\pgf@stop\else + \pgfcalendar@ifdate@first'1:#1\pgf@stop\fi}, + % logic + not/.value required, + not/.code=% + \begingroup + \let\pgf@cal@tempa\pgfutil@empty + \pgfcalendar@launch@ifdate{#1}{}{\def\pgf@cal@tempa{\pgfcalendarmatchestrue}}% + \expandafter\endgroup\pgf@cal@tempa, + and/.value required, + and/.code=% and = {<cond 1>, <cond 2>, <cond 3>, …} + \begingroup + \pgfcalendarmatchestrue + \pgfqkeys{/pgf/calendar/and}{#1}% + \ifpgfcalendarmatches % is it still true? + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi + {\def\pgf@cal@temp{\pgfcalendarmatchestrue}}% + {\let\pgf@cal@temp\pgfutil@empty}% + \expandafter\endgroup\pgf@cal@temp, + and/.unknown/.code=% only inside the group of and/.code + \ifpgfcalendarmatches + \expandafter\pgfutil@firstofone + \else + \expandafter\pgfutil@gobble + \fi + {% + \begingroup + \pgfcalendar@launch@ifdate{\pgfkeyscurrentname={#1}}% + {\let\pgf@cal@temp\pgfutil@empty}{\def\pgf@cal@temp{\pgfcalendarmatchesfalse}} + \expandafter\endgroup\pgf@cal@temp + },% + calendar week of month/.default=1, + calendar week of month'/.default=1, + calendar week of month/.code={% + \begingroup + \pgfutil@tempcnta=\pgfcalendarifdateday\relax + \advance\pgfutil@tempcnta by 5 + \advance\pgfutil@tempcnta by -\pgfcalendarifdateweekday\relax + \divide\pgfutil@tempcnta by 7 + \advance\pgfutil@tempcnta by -#1\relax + \expandafter\endgroup\expandafter + \ifnum\the\pgfutil@tempcnta=-1 + \pgfcalendarmatchestrue + \fi}, + calendar week of month'/.code={% + \begingroup + \pgfcalendar@getlastYMX\pgfcalendarifdateyear\pgfcalendarifdatemonth\pgfutil@tempcnta + \advance\pgfutil@tempcnta by -\pgfcalendarifdateday\relax + \edef\pgfcalendarifdateday{\the\pgfutil@tempcnta}% + \pgfutil@tempcnta=-\pgfcalendarifdateweekday\relax + \advance\pgfutil@tempcnta by 5 + \edef\pgfcalendarifdateweekday{\the\pgfutil@tempcnta}% + \let\pgf@cal@temp\pgfutil@empty + \pgfcalendar@launch@ifdate{calendar week of month={#1}}{\def\pgf@cal@temp{\pgfcalendarmatchestrue}}{}% + \expandafter\endgroup\pgf@cal@temp}} + +\def\pgfcalendar@ifdate@first#1#2:#3\pgf@stop{% + \pgfqkeys{/pgf/calendar}{and={#3, week of month#1={#2}}}} +\def\pgfcalendar@getlastYMX#1#2#3{% #1 = year, #2 = month, #3 := last day + \begingroup + \ifnum#2=2 % stupid February + \pgfcalendarmatchesfalse + \pgfqkeys{/pgf/calendar}{leap year={#1}}% + \ifpgfcalendarmatches + #3=29 + \else + #3=28 + \fi + \else + #3=\ifcase#2\relax\or + 31\or\or31\or30\or31\or30\or31\or31\or30\or31\or30\or31\fi + \fi + \edef\pgf@cal@temp{#3=\the#3\relax} + \expandafter + \endgroup\pgf@cal@temp} + +% +% weeks +% +\def\pgfcalendar@week@setup#1{% + \pgfutil@IfUndefined{pgfcalendar@week@#1}{% + \begingroup + \pgfcalendardatetojulian{#1-01-01}\pgfutil@tempcnta + \pgfcalendarjuliantoweekday\pgfutil@tempcnta\pgfutil@tempcntb + % + % tempcnta holds the julian number for first day of the current year + % tempcntb holds the weekday for the first day of the current year + % + % set tempcnta to the Monday of the week with first day of current year + \advance\pgfutil@tempcnta by -\pgfutil@tempcntb + % + % if the first week starts at Fri, Sat or Sun, next week is the 1st week + \ifnum\pgfutil@tempcntb>3\relax + \advance\pgfutil@tempcnta by 7\relax + \fi + % setup macro for year with {Julian number for day of first week}{weekday of -01-01} + \expandafter\xdef\csname pgfcalendar@week@#1\endcsname{{\the\pgfutil@tempcnta}{\the\pgfutil@tempcntb}}% + \endgroup + }{}% +} + +\def\pgfcalendarjulianyeartoweek#1#2#3{\pgfcalendarjulianyeartoweek@{#1}{#2}{#3}{\iftrue}} +\def\pgfcalendarjulianyeartoweek@#1#2#3#4{% + % #1 = julian date (count) + % #2 = year + % #3 = count that holds the week at the end + % #4 = \iftrue or \iffalse: whether week 53 needs to be checked (\iffalse when determing week from next year) + \begingroup + \pgfcalendar@week@setup{#2}% + #3=#1\relax + % + % calculate difference of days between current date and start of week 1 + % + \advance#3 by -\expandafter\expandafter\expandafter\pgfutil@firstoftwo\csname pgfcalendar@week@#2\endcsname\relax + \ifnum#3<0\relax % whoops, we are in the week of the previous year + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi + {% if first day of the year is Fri, Sat or Sun + \ifnum\expandafter\expandafter\expandafter\pgfutil@secondoftwo\csname pgfcalendar@week@#2\endcsname>3\relax + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi + {% we need to check the week of the previous year + #3=#2\relax + \advance#3 by -1 + \edef\pgf@cal@temp{\noexpand\pgfcalendarjulianyeartoweek@{#1}{\the#3}{#3}\noexpand\iffalse}% + \pgf@cal@temp + }{% yeah, it's weird + \divide#3 by 7 + \advance#3 by 1 + }% + }{% + \divide#3 by 7 + \advance#3 by 1 + #4% + \expandafter\pgfutil@firstofone + \else + \expandafter\pgfutil@gobble + \fi + {% + \ifnum#3=53\relax % whoops, we are possibly in the first week of the next year + \expandafter\pgfutil@firstofone + \else + \expandafter\pgfutil@gobble + \fi + {% + \begingroup + % check whether we're already in week 1 of the next year + #3=#2\relax + \advance#3 by 1 + \expandafter\pgfcalendar@week@setup\expandafter{\the#3}% + \ifnum#1<\expandafter\expandafter\expandafter\pgfutil@firstoftwo\csname pgfcalendar@week@\the#3\endcsname\relax + #3=53 + \else + #3=1 + \fi + \expandafter + \endgroup\expandafter#3\the#3\relax + }% + }% + }% + \expandafter + \endgroup\expandafter + #3\the#3\relax +} + +% +% shorthands for weeks (n) +% +% n-: shortest +% n=: shortest but prepends whitespace +% n0: leading zero +% +\expandafter\def\csname pgfcalendar@shorthand@n-\endcsname{% + \if0\pgfcalendarcurrentweek\else\pgfcalendarcurrentweek\fi} +\expandafter\def\csname pgfcalendar@shorthand@n=\endcsname{% + {\pgfutil@tempcnta=\pgfcalendarcurrentweek\relax\ifnum\pgfutil@tempcnta<10\relax\setbox0=\hbox{1}\kern\wd0\relax\fi\the\pgfutil@tempcnta}} +\expandafter\def\csname pgfcalendar@shorthand@n0\endcsname{% + \pgfcalendarcurrentweek} + +% +% Overwriting original \pgfcalendar +% +\long\def\pgfcalendar#1#2#3#4{% + \begingroup% + % Setup local \ifdate + \let\ifdate=\pgfcalendar@local@ifdate% + % Let's start with computing start and end dates... + \def\pgfcalendarprefix{#1}% + \pgfcalendardatetojulian{#2}{\pgfcalendarcurrentjulian}% + \edef\pgfcalendarbeginjulian{\the\pgfcalendarcurrentjulian}% + \edef\pgfcalendarbeginiso{#2}% + \pgfcalendardatetojulian{#3}{\pgfutil@tempcnta}% + \edef\pgfcalendarendjulian{\the\pgfutil@tempcnta}% + \advance\pgfutil@tempcnta by1\relax% + \edef\pgfcalendarendjulianplus{\the\pgfutil@tempcnta}% + \edef\pgfcalendarendiso{#3}% + % + % Start main loop + % + \loop% + \ifnum\pgfcalendarcurrentjulian<\pgfcalendarendjulianplus\relax% + % Setup information about current date + \pgfcalendarjuliantodate{\pgfcalendarcurrentjulian}% + {\pgfcalendarcurrentyear}{\pgfcalendarcurrentmonth}{\pgfcalendarcurrentday}% + \pgfcalendarjuliantoweekday{\pgfcalendarcurrentjulian}{\pgfutil@tempcntb}% + \edef\pgfcalendarcurrentweekday{\the\pgfutil@tempcntb}% + \pgfcalendarjulianyeartoweek{\pgfcalendarcurrentjulian}{\pgfcalendarcurrentyear}{\pgfutil@tempcntb}% + \edef\pgfcalendarcurrentweek{\ifnum\pgfutil@tempcntb<10 0\fi\the\pgfutil@tempcntb}% + % Render: + #4% + % Advance day: + \advance\pgfcalendarcurrentjulian by1\relax% + \repeat% + \endgroup% +} + +% +% Overwriting original \pgfcalendar@local@ifdate +% +\def\pgfcalendar@local@ifdate{% + \let\pgfcalendarifdatejulian=\pgfcalendarcurrentjulian + \let\pgfcalendarifdateyear=\pgfcalendarcurrentyear + \let\pgfcalendarifdatemonth=\pgfcalendarcurrentmonth + \let\pgfcalendarifdateday=\pgfcalendarcurrentday + \let\pgfcalendarifdateweekday=\pgfcalendarcurrentweekday + \let\pgfcalendarifdateweek=\pgfcalendarcurrentweek + \pgfcalendar@launch@ifdate% +} +% +% Overwritigin original \pgfcalendarifdate +% +\def\pgfcalendarifdate#1#2#3#4{% + \pgfcalendardatetojulian{#1}{\pgfutil@tempcnta}% + \pgfcalendarjuliantodate{\pgfutil@tempcnta} + {\pgfcalendarifdateyear}{\pgfcalendarifdatemonth}{\pgfcalendarifdateday}% + \edef\pgfcalendarifdatejulian{\the\pgfutil@tempcnta}% + % Compute info about date + \pgfcalendarjuliantoweekday{\pgfutil@tempcnta}{\pgfutil@tempcntb}% + \edef\pgfcalendarifdateweekday{\the\pgfutil@tempcntb}% + \pgfcalendarjulianyeartoweek{\pgfcalendarifdatejulian}{\pgfcalendarifdateyear}{\pgfutil@tempcntb}% + \edef\pgfcalendarifdateweek{\ifnum\pgfutil@tempcntb<10 0\fi\the\pgfutil@tempcntb}% + % + \pgfcalendar@launch@ifdate{#2}{#3}{#4}% +} + +\pgfqkeys{/pgf/calendar/week}{.value required,.code=\ifnum#1=\pgfcalendarifdateweek\relax\expandafter\pgfcalendarmatchestrue\fi} + +% Overwriting shorthands of pgfcalendar +\expandafter\def\csname pgfcalendar@shorthand@d-\endcsname{% + \if0\pgfcalendarcurrentday\else\pgfcalendarcurrentday\fi} +\expandafter\def\csname pgfcalendar@shorthand@m-\endcsname{% + \if0\pgfcalendarcurrentmonth\else\pgfcalendarcurrentmonth\fi} + +\endinput
\ No newline at end of file diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.circlearrow.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.circlearrow.code.tex new file mode 100644 index 0000000000..9eb1c6ab09 --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.circlearrow.code.tex @@ -0,0 +1,66 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +\pgfset{ + circle arrow start angle/.initial=, + circle arrow end angle/.initial=, + circle arrow delta angle/.initial=, + circle arrow arrows/.initial=-, + circle arrow/@turn left/.style={/pgf/circle arrow arrows=->,/pgf/circle arrow delta angle=340}, + circle arrow/@turn right/.style={/pgf/circle arrow arrows=<-,/pgf/circle arrow delta angle=340}, + circle arrow turn left north/.style = {/pgf/circle arrow/@turn left, /pgf/circle arrow start angle=100}, + circle arrow turn left east/.style = {/pgf/circle arrow/@turn left, /pgf/circle arrow start angle=10}, + circle arrow turn left south/.style = {/pgf/circle arrow/@turn left, /pgf/circle arrow start angle=280}, + circle arrow turn left west/.style = {/pgf/circle arrow/@turn left, /pgf/circle arrow start angle=190}, + circle arrow turn right north/.style = {/pgf/circle arrow/@turn right, /pgf/circle arrow start angle=100}, + circle arrow turn right east/.style = {/pgf/circle arrow/@turn right, /pgf/circle arrow start angle=10}, + circle arrow turn right south/.style = {/pgf/circle arrow/@turn right, /pgf/circle arrow start angle=280}, + circle arrow turn right west/.style = {/pgf/circle arrow/@turn right, /pgf/circle arrow start angle=190}, +} +\pgfdeclareshape{circle arrow}{ + \inheritsavedanchors[from=circle] + \inheritanchorborder[from=circle] + \inheritanchor[from=circle]{north} + \inheritanchor[from=circle]{north west} + \inheritanchor[from=circle]{north east} + \inheritanchor[from=circle]{center} + \inheritanchor[from=circle]{west} + \inheritanchor[from=circle]{east} + \inheritanchor[from=circle]{mid} + \inheritanchor[from=circle]{mid west} + \inheritanchor[from=circle]{mid east} + \inheritanchor[from=circle]{base} + \inheritanchor[from=circle]{base west} + \inheritanchor[from=circle]{base east} + \inheritanchor[from=circle]{south} + \inheritanchor[from=circle]{south west} + \inheritanchor[from=circle]{south east} + \backgroundpath{ + \pgfkeysgetvalue{/pgf/circle arrow start angle}\pgf@sh@circlearrow@s + \pgfkeysgetvalue{/pgf/circle arrow end angle}\pgf@sh@circlearrow@e + \pgfkeysgetvalue{/pgf/circle arrow delta angle}\pgf@sh@circlearrow@d + \ifx\pgf@sh@circlearrow@s\pgfutil@empty% + \pgfmathsetmacro\pgf@sh@circlearrow@s{\pgf@sh@circlearrow@e-\pgf@sh@circlearrow@d}% + \else + \ifx\pgf@sh@circlearrow@e\pgfutil@empty% + \pgfmathsetmacro\pgf@sh@circlearrow@e{\pgf@sh@circlearrow@s+\pgf@sh@circlearrow@d}% + \fi% + \fi + \pgfutil@tempdima=\radius + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xb<\pgf@yb + \advance\pgfutil@tempdima by-\pgf@yb + \else + \advance\pgfutil@tempdima by-\pgf@xb + \fi + \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfpointpolar{\pgf@sh@circlearrow@s}{\pgfutil@tempdima}}}% + \pgfpatharc{\pgf@sh@circlearrow@s}{\pgf@sh@circlearrow@e}{\pgfutil@tempdima}% + \pgfkeysgetvalue{/pgf/circle arrow arrows}\pgf@temp + \expandafter\pgfsetarrows\expandafter{\pgf@temp}% + } +}
\ No newline at end of file diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.circlecrosssplit.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.circlecrosssplit.code.tex new file mode 100644 index 0000000000..7bc2761fb4 --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.circlecrosssplit.code.tex @@ -0,0 +1,292 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +\usepgflibrary{shapes.multipart} +\let\pgfnodeparttrbox\pgfnodeparttwobox +\let\pgfnodepartblbox\pgfnodepartthreebox +\let\pgfnodepartbrbox\pgfnodepartfourbox +\newif\ifpgfcirclecrosssplitcustomfill +\pgfset{% + circle cross split part fill/.code=% + \def\pgf@lib@sh@ccs@list@fill{#1}% + \pgfcirclecrosssplitcustomfilltrue,% + circle cross split uses custom fill/.is if=pgfcirclecrosssplitcustomfill +} +\def\pgf@lib@sh@ccs@list@fill{none}% +\pgfdeclareshape{circle cross split}{% + \nodeparts{text,two,three,four}% + \savedanchor\centerpoint{% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/inner ysep}}% + \pgf@x =\wd\pgfnodeparttextbox + \pgf@yb=\dp\pgfnodeparttextbox + \pgf@y=\dp\pgfnodeparttwobox + \ifdim\pgf@yb>\pgf@y + \pgf@y=\pgf@yb + \fi + \advance\pgf@x\pgf@xa + \advance\pgf@y-\pgf@ya + \advance\pgf@x.5\pgflinewidth + \advance\pgf@y-.5\pgflinewidth + }% + \savedanchor\twoanchor{% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/inner ysep}}% + \advance\pgf@x.5\pgflinewidth + \advance\pgf@x\pgf@xa + \advance\pgf@y.5\pgflinewidth + \advance\pgf@y\pgf@ya + \pgf@yb\dp\pgfnodeparttextbox + \pgf@yc\dp\pgfnodeparttwobox + \ifdim\pgf@yb>\pgf@yc + \pgf@yc\pgf@yb + \fi + \advance\pgf@y\pgf@yc + }% + \savedanchor\threeanchor{% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/inner ysep}}% + \pgf@x\wd\pgfnodeparttextbox + \pgf@yb\dp\pgfnodeparttextbox + \pgf@yc\dp\pgfnodeparttwobox + \ifdim\pgf@yb>\pgf@yc + \pgf@yc\pgf@yb + \fi + \advance\pgf@y-\pgf@yc + \advance\pgf@y-2\pgf@ya + \advance\pgf@y-\pgflinewidth + \pgf@yb\ht\pgfnodepartthreebox + \pgf@yc\ht\pgfnodepartfourbox + \ifdim\pgf@yb>\pgf@yc + \pgf@yc\pgf@yb + \fi + \advance\pgf@y-\pgf@yc + \advance\pgf@x-\wd\pgfnodepartthreebox + }% + \saveddimen\radius{% + % height (upper): + \pgf@y=\ht\pgfnodeparttextbox + \ifdim\pgf@y<\ht\pgfnodeparttwobox + \pgf@y=\ht\pgfnodeparttwobox + \fi + \ifdim\dp\pgfnodeparttextbox>\dp\pgfnodeparttwobox + \advance\pgf@y by\dp\pgfnodeparttextbox + \else + \advance\pgf@y by\dp\pgfnodeparttwobox + \fi + % height (lower): + \pgf@yb\ht\pgfnodepartthreebox + \ifdim\pgf@yb<\ht\pgfnodepartfourbox + \pgf@yb=\ht\pgfnodepartfourbox + \fi + \pgf@yc=\dp\pgfnodepartthreebox + \ifdim\pgf@yc<\dp\pgfnodepartfourbox + \advance\pgf@yb by\dp\pgfnodepartfourbox + \else + \advance\pgf@yb by\pgf@yc + \fi + \ifdim\pgf@yc>\pgf@y + \pgf@y=\pgf@yc + \fi + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/inner ysep}}% + \advance\pgf@y2\pgf@ya + % + \pgf@x\wd\pgfnodeparttextbox + \pgf@xa\wd\pgfnodepartthreebox + \pgf@xb\wd\pgfnodeparttwobox + \pgf@xc\wd\pgfnodepartfourbox + \ifdim\pgf@xa>\pgf@x + \pgf@x\pgf@xa + \fi + \ifdim\pgf@xb>\pgf@x + \pgf@x\pgf@xb + \fi + \ifdim\pgf@xc>\pgf@x + \pgf@x\pgf@xc + \fi + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}% + \advance\pgf@x by 2\pgf@xa + \ifdim\pgf@y>\pgf@x + \pgf@x=\pgf@y + \fi + \advance\pgf@x by\pgflinewidth + % + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + % from circle: + \pgf@process{\pgfpointnormalised{}}% + \ifdim\pgf@x>\pgf@y% + \c@pgf@counta=\pgf@x% + \ifnum\c@pgf@counta=0\relax% + \else% + \divide\c@pgf@counta by 255\relax% + \pgf@xa=16\pgf@xa\relax% + \divide\pgf@xa by\c@pgf@counta% + \pgf@xa=16\pgf@xa\relax% + \fi% + \else% + \c@pgf@counta=\pgf@y% + \ifnum\c@pgf@counta=0\relax% + \else% + \divide\c@pgf@counta by 255\relax% + \pgf@ya=16\pgf@ya\relax% + \divide\pgf@ya by\c@pgf@counta% + \pgf@xa=16\pgf@ya\relax% + \fi% + \fi% + \pgf@x=\pgf@xa% + % + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/minimum width}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/minimum height}}% + \ifdim\pgf@x<.5\pgf@xb + \pgf@x=.5\pgf@xb + \fi + \ifdim\pgf@x<.5\pgf@yb + \pgf@x=.5\pgf@yb + \fi + % + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xb<\pgf@yb + \advance\pgf@x\pgf@yb + \else + \advance\pgf@x\pgf@xb + \fi + }% + \inheritanchorborder[from=circle]% + \inheritanchor[from=circle]{north}% + \inheritanchor[from=circle]{north west}% + \inheritanchor[from=circle]{north east}% + \inheritanchor[from=circle]{center}% + \inheritanchor[from=circle]{west}% + \inheritanchor[from=circle]{east}% + \inheritanchor[from=circle]{mid}% + \inheritanchor[from=circle]{mid west}% + \inheritanchor[from=circle]{mid east}% + \inheritanchor[from=circle]{base}% + \inheritanchor[from=circle]{base west}% + \inheritanchor[from=circle]{base east}% + \inheritanchor[from=circle]{south}% + \inheritanchor[from=circle]{south west}% + \inheritanchor[from=circle]{south east}% + \anchor{two}{\twoanchor}% + \anchor{three}{\threeanchor}% + \anchor{four}{ + \threeanchor + \pgf@ya=\pgf@y + \twoanchor + \pgf@y=\pgf@ya + }% + \anchor{lower base}{% + \threeanchor + \pgf@ya=\pgf@y + \centerpoint + \pgf@y=\pgf@ya + } + \anchor{lower base west}{% + \threeanchor + \pgf@ya=\pgf@y + \centerpoint + \pgf@y=\pgf@ya + \advance\pgf@x by-\radius + } + \anchor{lower base east}{% + \threeanchor + \pgf@ya=\pgf@y + \centerpoint + \pgf@y=\pgf@ya + \advance\pgf@x by\radius + } + \anchor{lower mid}{% + \threeanchor + \pgf@ya=\pgf@y + \centerpoint + \pgf@y=\pgf@ya + \pgfmathsetlength\pgf@ya{+.5ex}% + \advance\pgf@y by\pgf@ya + } + \anchor{lower mid west}{% + \threeanchor + \pgf@ya=\pgf@y + \centerpoint + \pgf@y=\pgf@ya + \advance\pgf@x by-\radius + \pgfmathsetlength\pgf@ya{+.5ex}% + \advance\pgf@y by\pgf@ya + } + \anchor{lower mid east}{% + \threeanchor + \pgf@ya=\pgf@y + \centerpoint + \pgf@y=\pgf@ya + \advance\pgf@x by\radius + \pgfmathsetlength\pgf@ya{+.5ex}% + \advance\pgf@y by\pgf@ya + } + \inheritbackgroundpath[from=circle] + \beforebackgroundpath{% + \pgfutil@tempdima=\radius + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xb<\pgf@yb + \advance\pgfutil@tempdima by-\pgf@yb + \else + \advance\pgfutil@tempdima by-\pgf@xb + \fi + \advance\pgfutil@tempdima by-.5\pgflinewidth% + \pgfsetshortenstart{0pt}% + \pgfsetshortenend{0pt}% + \pgfsetarrows{-}% + \pgfpathmoveto + {\pgfpointadd{\centerpoint}{\pgfqpoint{-\pgfutil@tempdima}{0pt}}}% + \pgfpathlineto + {\pgfpointadd{\centerpoint}{\pgfqpoint{\pgfutil@tempdima}{0pt}}}% + \pgfpathmoveto + {\pgfpointadd{\centerpoint}{\pgfqpoint{0pt}{-\pgfutil@tempdima}}}% + \pgfpathlineto + {\pgfpointadd{\centerpoint}{\pgfqpoint{0pt}{\pgfutil@tempdima}}}% + \pgfusepathqstroke + }% + \behindbackgroundpath{% + \pgfutil@tempdima=\radius + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xb<\pgf@yb + \advance\pgfutil@tempdima by-\pgf@yb + \else + \advance\pgfutil@tempdima by-\pgf@xb + \fi + \advance\pgfutil@tempdima by-.5\pgflinewidth% + \ifpgfcirclecrosssplitcustomfill% + \pgf@lib@sh@rs@process@list{\pgf@lib@sh@ccs@list@fill}{4}% + {% + \pgfmathloop + \ifnum\pgfmathcounter>4% + \else% + \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}% + \edef\pgf@tempa + {\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname}% + \ifx\pgf@tempa\pgf@lib@sh@rs@nonetext\else + \pgfsetfillcolor{\pgf@tempa}% + \ifcase\pgfmathcounter\or + \def\pgf@lib@sh@ccs@angle{90}\or + \def\pgf@lib@sh@ccs@angle{0}\or + \def\pgf@lib@sh@ccs@angle{180}\else + \def\pgf@lib@sh@ccs@angle{270}% + \fi + \pgfpathmoveto{\centerpoint}% + \pgfpathlineto{\pgfpointadd{\centerpoint} + {\pgfqpointpolar{\pgf@lib@sh@ccs@angle}{\pgfutil@tempdima}}}% + \pgfpatharc{+\pgf@lib@sh@ccs@angle}{\pgf@lib@sh@ccs@angle+90} + {+\pgfutil@tempdima}% + \pgfpathclose + \pgfusepathqfill + \fi + \repeatpgfmathloop + }% + \fi + }% +}
\ No newline at end of file diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.heatmark.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.heatmark.code.tex new file mode 100644 index 0000000000..477d0442da --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.heatmark.code.tex @@ -0,0 +1,181 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +\pgfset{ + heatmark arc width/.initial=+4pt, + heatmark arc sep/.initial=+1pt, + heatmark arc rings/.initial=3, + heatmark arcs/.initial=3, + heatmark arc sep angle/.initial=20, + heatmark inner opacity/.initial=.8, + heatmark outer opacity/.initial=.2 +} +\pgfdeclareshape{heatmark} +% +% Draws a circle around the text +% +{ + \savedanchor\centerpoint{% + \pgf@x=.5\wd\pgfnodeparttextbox% + \pgf@y=.5\ht\pgfnodeparttextbox% + \advance\pgf@y by-.5\dp\pgfnodeparttextbox% + } + + \saveddimen\innerradius{% + % + % Caculate ``height radius'' + % + \pgf@ya=.5\ht\pgfnodeparttextbox% + \advance\pgf@ya by.5\dp\pgfnodeparttextbox% + \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/inner ysep}}% + \advance\pgf@ya by\pgf@yb% + % + % Caculate ``width radius'' + % + \pgf@xa=.5\wd\pgfnodeparttextbox% + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/inner xsep}}% + \advance\pgf@xa by\pgf@xb% + % + % Calculate length of radius vector: + % + \pgf@process{\pgfpointnormalised{\pgfqpoint{\pgf@xa}{\pgf@ya}}}% + \ifdim\pgf@x>\pgf@y% + \c@pgf@counta=\pgf@x% + \ifnum\c@pgf@counta=0\relax% + \else% + \divide\c@pgf@counta by 255\relax% + \pgf@xa=16\pgf@xa\relax% + \divide\pgf@xa by\c@pgf@counta% + \pgf@xa=16\pgf@xa\relax% + \fi% + \else% + \c@pgf@counta=\pgf@y% + \ifnum\c@pgf@counta=0\relax% + \else% + \divide\c@pgf@counta by 255\relax% + \pgf@ya=16\pgf@ya\relax% + \divide\pgf@ya by\c@pgf@counta% + \pgf@xa=16\pgf@ya\relax% + \fi% + \fi% + \pgf@x=\pgf@xa% + % + % If necessary, adjust radius so that the size requirements are + % met: + % + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/minimum width}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/minimum height}}% + \ifdim\pgf@x<.5\pgf@xb% + \pgf@x=.5\pgf@xb% + \fi% + \ifdim\pgf@x<.5\pgf@yb% + \pgf@x=.5\pgf@yb% + \fi% + }% + + \saveddimen\radius{% + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xb<\pgf@yb% + \advance\pgf@x by\pgf@yb% + \else% + \advance\pgf@x by\pgf@xb% + \fi% + \pgfmathsetcount\c@pgf@counta{\pgfkeysvalueof{/pgf/heatmark arc rings}}% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/heatmark arc width}+\pgfkeysvalueof{/pgf/heatmark arc sep}}% + \multiply\pgf@xa\c@pgf@counta + \advance\pgf@x\pgf@xa + }% + % + % Anchors + % + \inheritanchor[from=circle]{north} + \inheritanchor[from=circle]{north west} + \inheritanchor[from=circle]{north east} + \inheritanchor[from=circle]{center} + \inheritanchor[from=circle]{west} + \inheritanchor[from=circle]{east} + \inheritanchor[from=circle]{mid} + \inheritanchor[from=circle]{mid west} + \inheritanchor[from=circle]{mid east} + \inheritanchor[from=circle]{base} + \inheritanchor[from=circle]{base west} + \inheritanchor[from=circle]{base east} + \inheritanchor[from=circle]{south} + \inheritanchor[from=circle]{south west} + \inheritanchor[from=circle]{south east} + \inheritanchorborder[from=circle] + % + % Background path + % + \backgroundpath{ + \pgfutil@tempdima=\innerradius% + \pgfpathcircle{\centerpoint}{\pgfutil@tempdima}% + }% + % + % + % + \behindbackgroundpath{% + \pgfmathsetcount\c@pgf@counta{\pgfkeysvalueof{/pgf/heatmark arc rings}}% heat arc rings + \pgfmathsetcount\c@pgf@countb{\pgfkeysvalueof{/pgf/heatmark arcs}}% heat arcs + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/heatmark arc width}}% heat arc width + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/heatmark arc sep}}% heat arc sep + %\pgfmathsetmacro\pgf@tempa{\pgfkeysvalueof{/pgf/heat arc sep angle}}% heat arc sep angle + \pgfmathsetmacro\pgf@tempb{360/\c@pgf@countb-(\pgfkeysvalueof{/pgf/heatmark arc sep angle})}% heat arc + \pgfmathsetmacro\pgf@tempc{\pgfkeysvalueof{/pgf/shape border rotate}}% heat rotate + % + \pgfmathsetmacro\pgf@tempd{\pgfkeysvalueof{/pgf/heatmark inner opacity}}% heat opacity high + \ifnum\c@pgf@counta=1 + \def\tikzext@heatmark@opacity@seps{0}% + \else + \pgfmathsetmacro\tikzext@heatmark@opacity@seps + {(\pgf@tempd-(\pgfkeysvalueof{/pgf/heatmark outer opacity}))% + /(\c@pgf@counta-1)}% + \fi + \pgfutil@tempcnta=0 + \pgfutil@tempcntb=0 + \pgf@ya\innerradius\relax + \pgftransformshift{\centerpoint} + \pgfutil@loop % ring loop + \advance\pgf@ya\pgf@xb % current radius + heat arc sep + \pgf@yb\pgf@ya + \advance\pgf@yb\pgf@xa % current radius + heat arc sep + heat arc width + \pgfsetfillopacity{\pgf@tempd}% + \begingroup + \edef\pgf@marshal{\noexpand\pgfset{heatmark ring \the\numexpr\pgfutil@tempcnta+1\relax/.try}}% + \pgf@marshal + \csname tikz@options\endcsname + {% + \pgfutil@loop + \pgfmathsetmacro\tikzext@heatmark@start@angle{\pgf@tempc-.5*\pgf@tempb+\pgfutil@tempcntb*(360/\c@pgf@countb)}% + % path + \begingroup + \edef\pgf@marshal{\noexpand\pgfset{heatmark arc \the\numexpr\pgfutil@tempcntb+1\relax/.try}% + \noexpand\pgfset{heatmark ring \the\numexpr\pgfutil@tempcnta+1\relax\space arc \the\numexpr\pgfutil@tempcntb+1\relax/.try}}% + \pgf@marshal + \csname tikz@options\endcsname + \pgfpathmoveto{\pgfpointpolar{\tikzext@heatmark@start@angle}{\pgf@ya}}% + \pgfpatharc{\tikzext@heatmark@start@angle}{\tikzext@heatmark@start@angle+\pgf@tempb}{\pgf@ya}% + \pgfpathlineto{\pgfpointpolar{\tikzext@heatmark@start@angle+\pgf@tempb}{\pgf@yb}}% + \pgfpatharc{\tikzext@heatmark@start@angle+\pgf@tempb}{\tikzext@heatmark@start@angle}{\pgf@yb}% + \pgfpathclose + \pgfusepathqfill + \endgroup + \advance\pgfutil@tempcntb\@ne + \ifnum\pgfutil@tempcntb<\c@pgf@countb + \pgfutil@repeat + }% + \endgroup + \advance\pgfutil@tempcnta\@ne + \ifnum\pgfutil@tempcnta<\c@pgf@counta + \pgf@ya\pgf@yb + \pgfmathsetmacro\pgf@tempd{\pgf@tempd-\tikzext@heatmark@opacity@seps}% + \pgfutil@repeat + \pgftransformshift{\pgfqpointscale{-1}{\centerpoint}}% + } +} +\endinput diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.rectangleroundedcorners.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.rectangleroundedcorners.code.tex new file mode 100644 index 0000000000..37baf7abbf --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.rectangleroundedcorners.code.tex @@ -0,0 +1,318 @@ +\pgfset{ + rectangle with rounded corners north west radius/.initial=.5\pgflinewidth, + rectangle with rounded corners north east radius/.initial=.5\pgflinewidth, + rectangle with rounded corners south west radius/.initial=.5\pgflinewidth, + rectangle with rounded corners south east radius/.initial=.5\pgflinewidth, + rectangle with rounded corners radius/.style={ + /pgf/rectangle with rounded corners north west radius={#1}, + /pgf/rectangle with rounded corners north east radius={#1}, + /pgf/rectangle with rounded corners south west radius={#1}, + /pgf/rectangle with rounded corners south east radius={#1}} +}% +\pgfdeclareshape{rectangle with rounded corners}{% + \savedmacro\rectanglewithroundedcornersparameter{% + % + % width = max(text width + 2 * inner xseps, minimum width) + 2 * outer xseps + \pgf@x=\wd\pgfnodeparttextbox + \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/inner xsep}}% + \advance\pgf@x by 2\pgf@xc + \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/minimum width}}% + \ifdim\pgf@x<\pgf@xc + \pgf@x=\pgf@xc + \fi + % + \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/outer xsep}}% + \edef\outerxsep{\the\pgf@xc}% + \addtosavedmacro\outerxsep + \advance\pgf@x by 2\pgf@xc + \pgf@x=.5\pgf@x + \edef\halfwidth{\the\pgf@x}% + \addtosavedmacro\halfwidth + % + % height = max(text height + text depth + 2 * inner yseps, minimum height) + 2 * outer yseps + \pgf@y=\ht\pgfnodeparttextbox + \advance\pgf@y by \dp\pgfnodeparttextbox + \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/inner ysep}}% + \advance\pgf@y by 2\pgf@yc + \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/minimum height}}% + \ifdim\pgf@y<\pgf@yc + \pgf@y=\pgf@yc + \fi + % + \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/outer ysep}}% + \edef\outerysep{\the\pgf@yc}% + \addtosavedmacro\outerysep + \advance\pgf@y by 2\pgf@yc + \pgf@y=.5\pgf@y + \edef\halfheight{\the\pgf@y}% + \addtosavedmacro\halfheight + % + % \centerpoint + \pgf@x=.5\wd\pgfnodeparttextbox + \pgf@y=.5\ht\pgfnodeparttextbox + \advance\pgf@y by -.5\dp\pgfnodeparttextbox + \pgfextract@process\centerpoint{}% + \addtosavedmacro\centerpoint + % + \pgfmathsetlengthmacro\northwestradius{\pgfkeysvalueof{/pgf/rectangle with rounded corners north west radius}} + \pgfmathsetlengthmacro\northeastradius{\pgfkeysvalueof{/pgf/rectangle with rounded corners north east radius}} + \pgfmathsetlengthmacro\southwestradius{\pgfkeysvalueof{/pgf/rectangle with rounded corners south west radius}} + \pgfmathsetlengthmacro\southeastradius{\pgfkeysvalueof{/pgf/rectangle with rounded corners south east radius}} + \addtosavedmacro\northwestradius + \addtosavedmacro\northeastradius + \addtosavedmacro\southwestradius + \addtosavedmacro\southeastradius + }% + \anchor{center}{% + \rectanglewithroundedcornersparameter + \centerpoint + } + \anchor{west}{% + \rectanglewithroundedcornersparameter + \centerpoint + \advance\pgf@x by -\halfwidth + } + \anchor{east}{% + \rectanglewithroundedcornersparameter + \centerpoint + \advance\pgf@x by \halfwidth + } + \anchor{north}{% + \rectanglewithroundedcornersparameter + \centerpoint + \advance\pgf@y by \halfheight + } + \anchor{south}{% + \rectanglewithroundedcornersparameter + \centerpoint + \advance\pgf@y by -\halfheight + } + \anchor{mid}{% + \rectanglewithroundedcornersparameter + \centerpoint + \pgfmathsetlength\pgf@y{+.5ex}% + } + \anchor{mid west}{% + \csname pgf@anchor@rectangle with rounded corners@west\endcsname + \pgfmathsetlength\pgf@y{+.5ex}% + } + \anchor{mid east}{% + \csname pgf@anchor@rectangle with rounded corners@east\endcsname + \pgfmathsetlength\pgf@y{+.5ex}% + } + \anchor{base}{% + \rectanglewithroundedcornersparameter + \centerpoint + \pgf@y=0pt + } + \anchor{base west}{% + \csname pgf@anchor@rectangle with rounded corners@west\endcsname + \pgf@y=0pt + } + \anchor{base east}{% + \csname pgf@anchor@rectangle with rounded corners@east\endcsname + \pgf@y=0pt + } + \anchor{north west}{% + \csname pgf@anchor@rectangle with rounded corners@north west center\endcsname + \ifdim\northwestradius=0pt + \else + \pgf@process{\pgfpointadd{}{\pgfpointpolar{135}{\northwestradius+\outerxsep and \northwestradius+\outerysep}}}% + \fi + } + \anchor{north west center}{% + \rectanglewithroundedcornersparameter + \pgf@x=-\halfwidth + \pgf@y=\halfheight + \ifdim\northwestradius=0pt + \else + \advance\pgf@x by \outerxsep + \advance\pgf@x by \northwestradius + \advance\pgf@y by -\outerysep + \advance\pgf@y by -\northwestradius + \fi + \pgf@process{\pgfpointadd{}{\centerpoint}}% + } + \anchor{north east}{% + \csname pgf@anchor@rectangle with rounded corners@north east center\endcsname + \ifdim\northeastradius=0pt + \else + \pgf@process{\pgfpointadd{}{\pgfpointpolar{45}{\northeastradius+\outerxsep and \northeastradius+\outerysep}}}% + \fi + } + \anchor{north east center}{% + \rectanglewithroundedcornersparameter + \pgf@x=\halfwidth + \pgf@y=\halfheight + \ifdim\northeastradius=0pt + \else + \advance\pgf@x by -\outerxsep + \advance\pgf@x by -\northeastradius + \advance\pgf@y by -\outerysep + \advance\pgf@y by -\northeastradius + \fi + \pgf@process{\pgfpointadd{}{\centerpoint}}% + } + \anchor{south west}{% + \csname pgf@anchor@rectangle with rounded corners@south west center\endcsname + \ifdim\southwestradius=0pt + \else + \pgf@process{\pgfpointadd{}{\pgfpointpolar{225}{\southwestradius+\outerxsep and \southwestradius+\outerysep}}}% + \fi + } + \anchor{south west center}{% + \rectanglewithroundedcornersparameter + \pgf@x=-\halfwidth + \pgf@y=-\halfheight + \ifdim\southwestradius=0pt + \else + \advance\pgf@x by \outerxsep + \advance\pgf@x by \southwestradius + \advance\pgf@y by \outerysep + \advance\pgf@y by \southwestradius + \fi + \pgf@process{\pgfpointadd{}{\centerpoint}}% + } + \anchor{south east}{% + \csname pgf@anchor@rectangle with rounded corners@south east center\endcsname + \ifdim\southeastradius=0pt + \else + \pgf@process{\pgfpointadd{}{\pgfpointpolar{315}{\southeastradius+\outerxsep and \southeastradius+\outerysep}}}% + \fi + } + \anchor{south east center}{% + \rectanglewithroundedcornersparameter + \pgf@x=\halfwidth + \pgf@y=-\halfheight + \ifdim\southeastradius=0pt + \else + \advance\pgf@x by -\outerxsep + \advance\pgf@x by -\southeastradius + \advance\pgf@y by \outerysep + \advance\pgf@y by \southeastradius + \fi + \pgf@process{\pgfpointadd{}{\centerpoint}}% + } + \anchor{below north west}{% + \csname pgf@anchor@rectangle with rounded corners@north west center\endcsname + \advance\pgf@x by -\northwestradius + \advance\pgf@x by -\outerxsep + } + \anchor{above south west}{% + \csname pgf@anchor@rectangle with rounded corners@south west center\endcsname + \advance\pgf@x by -\southwestradius + \advance\pgf@x by -\outerxsep + } + \anchor{below north east}{% + \csname pgf@anchor@rectangle with rounded corners@north east center\endcsname + \advance\pgf@x by \northeastradius + \advance\pgf@x by \outerxsep + } + \anchor{above south east}{% + \csname pgf@anchor@rectangle with rounded corners@south east center\endcsname + \advance\pgf@x by \southeastradius + \advance\pgf@x by \outerxsep + } + \anchor{right north west}{% + \csname pgf@anchor@rectangle with rounded corners@north west center\endcsname + \advance\pgf@y by \northwestradius + \advance\pgf@y by \outerysep + } + \anchor{right south west}{% + \csname pgf@anchor@rectangle with rounded corners@south west center\endcsname + \advance\pgf@y by -\southwestradius + \advance\pgf@y by -\outerysep + } + \anchor{left north east}{% + \csname pgf@anchor@rectangle with rounded corners@north east center\endcsname + \advance\pgf@y by \northeastradius + \advance\pgf@y by \outerysep + } + \anchor{left south east}{% + \csname pgf@anchor@rectangle with rounded corners@south east center\endcsname + \advance\pgf@y by -\southeastradius + \advance\pgf@y by -\outerysep + } + \backgroundpath{% + \rectanglewithroundedcornersparameter + % + \pgf@xa=\halfwidth + \advance\pgf@xa by -\outerxsep + \edef\HalfWidth{\the\pgf@xa}% + % + \pgf@ya=\halfheight + \advance\pgf@ya by -\outerysep + \edef\HalfHeight{\the\pgf@ya}% + % + \pgftransformshift{\centerpoint}% + % + \pgfpathmoveto{\pgfqpoint{\HalfWidth}{0pt}}% + \pgfpathlineto{\pgfpoint {+\HalfWidth}{\HalfHeight-\northeastradius}}% + \pgfpatharc{0}{90}{\northeastradius}% + \pgfpathlineto{\pgfpoint{-\HalfWidth+\northwestradius}{+\HalfHeight}} + \pgfpatharc{90}{180}{\northwestradius}% + \pgfpathlineto{\pgfpoint{+-\HalfWidth}{-\HalfHeight+\southwestradius}}% + \pgfpatharc{180}{270}{\southwestradius}% + \pgfpathlineto{\pgfpoint{\HalfWidth-\southeastradius}{+-\HalfHeight}}% + \pgfpatharc{270}{360}{\southeastradius}% + \pgfpathclose + \pgftransformshift{\pgfqpointscale{-1}{\centerpoint}}% + }% + \anchorborder{% + \pgfextract@process\externalpoint{}% + \ifdim\pgf@x=0pt + \ifdim\pgf@y<0pt + \csname pgf@anchor@rectangle with rounded corners@south\endcsname + \else + \csname pgf@anchor@rectangle with rounded corners@north\endcsname + \fi + \else + \ifdim\pgf@y=0pt + \ifdim\pgf@x<0pt + \csname pgf@anchor@rectangle with rounded corners@west\endcsname + \else + \csname pgf@anchor@rectangle with rounded corners@east\endcsname + \fi + \else + \rectanglewithroundedcornersparameter + \pgfmathanglebetweenpoints{\pgfpointorigin}{\externalpoint}% + \let\angle\pgfmathresult + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgfextract@process\externalPoint{\pgfpointadd{}{\centerpoint}}% + \ifdim\pgf@xa<0pt + \ifdim\pgf@ya<0pt + % south west + \pgf@sh@rwrc@anchorborder{above south west}{right south west}{south west}{180}{270}{\southwestradius}% + \else + % north west + \pgf@sh@rwrc@anchorborder{right north west}{below north west}{north west}{90}{180}{\northwestradius}% + \fi + \else + \ifdim\pgf@ya<0pt + % south east + \pgf@sh@rwrc@anchorborder{left south east}{above south east}{south east}{270}{360}{\southeastradius}% + \else + % north east + \pgf@sh@rwrc@anchorborder{below north east}{left north east}{north east}{0}{90}{\northeastradius}% + \fi + \fi + \fi + \fi + } +} +\def\pgf@sh@rwrc@anchorborder#1#2#3#4#5#6{% + \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rectangle with rounded corners@#1\endcsname}% + \let\angleA\pgfmathresult + \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rectangle with rounded corners@#2\endcsname}% + \let\angleB\pgfmathresult + \if\ifdim\angle pt>\angleA pt 0\else1\fi\ifdim\angle pt<\angleB pt 0\else 2\fi + \pgfmathpointintersectionoflineandarc{\externalPoint}{\centerpoint} + {\csname pgf@anchor@rectangle with rounded corners@#3 center\endcsname} + {#4}{#5}{#6+\outerxsep and #6+\outerysep}% + \else + \pgf@process{\pgfpointadd{\pgfpointborderrectangle{\externalpoint}{\pgfqpoint{\halfwidth}{\halfheight}}}{\centerpoint}}% + \fi +} + +\endinput diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.superellipse.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.superellipse.code.tex new file mode 100644 index 0000000000..9a89b5a8a6 --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.shapes.superellipse.code.tex @@ -0,0 +1,198 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +\usepgflibrary{shapes.geometric,intersections} +\pgfset{ + superellipse x exponent/.initial=2.5, + superellipse y exponent/.initial=2.5, + superellipse step/.initial=4, + superellipse exponent/.style={/pgf/superellipse x exponent={#1},/pgf/superellipse y exponent={#1}}} + +% Evaluates the x-value of a superellipse around the center +% #1 = t (0≤t≤90) +% #2 = 2/m (x-exp) +% #3 = a (x-rad) +\pgfmathdeclarefunction{superellipsex}{3}{% + \pgfmathcos@{#1}% + \pgfmathpow@{\pgfmathresult}{#2}% + \pgfmathmultiply@{\pgfmathresult}{#3}} + +% Evaluates the y-value of a superellipse around the center +% #1 = t (0≤t≤90) +% #2 = 2/n (y-exp) +% #3 = a (y-rad) +\pgfmathdeclarefunction{superellipsey}{3}{% + \pgfmathsin@{#1}% + \pgfmathpow@{\pgfmathresult}{#2}% + \pgfmathmultiply@{\pgfmathresult}{#3}} + +% Evaluates the x- and y- value of superellipse around the center +% #1 = t (0≤t≤90) +% #2 = 2/m (x-exp) +% #3 = 2/n (y-exp) +% #4 = a (x-rad) +% #5 = b (y-rad) +\def\pgfmathsuperellipseXY#1#2#3#4#5{% + \begingroup + \pgfmathsuperellipsex@{#1}{#2}{#4}% + \let\pgfmath@temp\pgfmathresult + \pgfmathsuperellipsey@{#1}{#3}{#5}% + \edef\pgfmath@temp{\def\noexpand\pgfmathresultX{\pgfmath@temp}% + \def\noexpand\pgfmathresultY{\pgfmathresult}}% + \expandafter + \endgroup\pgfmath@temp} + +\pgfdeclareshape{superellipse}{% + \inheritsavedanchors[from=ellipse] + \inheritanchor[from=ellipse]{text}\inheritanchor[from=ellipse]{center} + \inheritanchor[from=ellipse]{mid}\inheritanchor[from=ellipse]{base} + \inheritanchor[from=ellipse]{north}\inheritanchor[from=ellipse]{south} + \inheritanchor[from=ellipse]{west}\inheritanchor[from=ellipse]{east} + \inheritanchor[from=ellipse]{mid west}\inheritanchor[from=ellipse]{base west} + \inheritanchor[from=ellipse]{mid east}\inheritanchor[from=ellipse]{base east} + \anchor{north east}{% + \pgf@process{\radius}% + \pgfmathpow@{.70710678118}{\xexponent}% + \pgf@x=\pgfmathresult\pgf@x + \pgfmathpow@{.70710678118}{\yexponent}% + \pgf@y=\pgfmathresult\pgf@y + \pgfpointadd{}{\centerpoint}% + } + \anchor{north west}{% + \pgf@process{\radius}% + \pgfmathpow@{.70710678118}{\xexponent}% + \pgf@x=-\pgfmathresult\pgf@x + \pgfmathpow@{.70710678118}{\yexponent}% + \pgf@y=\pgfmathresult\pgf@y + \pgfpointadd{}{\centerpoint}% + } + \anchor{south west}{% + \pgf@process{\radius}% + \pgfmathpow@{.70710678118}{\xexponent}% + \pgf@x=-\pgfmathresult\pgf@x + \pgfmathpow@{.70710678118}{\yexponent}% + \pgf@y=-\pgfmathresult\pgf@y + \pgfpointadd{}{\centerpoint}% + } + \anchor{south east}{% + \pgf@process{\radius}% + \pgfmathpow@{.70710678118}{\xexponent}% + \pgf@x=\pgfmathresult\pgf@x + \pgfmathpow@{.70710678118}{\yexponent}% + \pgf@y=-\pgfmathresult\pgf@y + \pgfpointadd{}{\centerpoint}% + } + \savedmacro\xexponent{% + \pgfmathreciprocal{\pgfkeysvalueof{/pgf/superellipse x exponent}}% + \pgfmathmultiply@{\pgfmathresult}{2}% + \let\xexponent\pgfmathresult + } + \savedmacro\yexponent{% + \pgfmathreciprocal{\pgfkeysvalueof{/pgf/superellipse y exponent}}% + \pgfmathmultiply@{\pgfmathresult}{2}% + \let\yexponent\pgfmathresult + } + \savedmacro\step{% + \pgfmathtruncatemacro\step{\pgfkeysvalueof{/pgf/superellipse step}}% + } + \backgroundpath{% + \pgf@process{\radius}% + \pgfmathsetmacro\xradius{\pgf@x-(\pgfkeysvalueof{/pgf/outer xsep})}% + \pgfmathsetmacro\yradius{\pgf@y-(\pgfkeysvalueof{/pgf/outer ysep})}% + \let\pgf@tempa\pgfutil@empty\let\pgf@tempb\pgfutil@empty + \let\pgf@tempc\pgfutil@empty\let\pgf@tempd\pgfutil@empty + \c@pgf@counta=\step + \pgfutil@loop + \ifnum\c@pgf@counta<90 + \pgfmathsuperellipseXY{\the\c@pgf@counta}{\xexponent}{\yexponent}{\xradius}{\yradius}% + \edef\pgf@temp{\noexpand\pgfplotstreampoint{\noexpand\pgfqpoint{\pgfmathresultX pt}{\pgfmathresultY pt}}}% + \pgfutil@append@macrotomacro\pgf@tempa\pgf@temp + \edef\pgf@temp{\noexpand\pgfplotstreampoint{\noexpand\pgfqpoint{-\pgfmathresultX pt}{\pgfmathresultY pt}}}% + \pgfutil@prefix@macrotomacro\pgf@tempb\pgf@temp + \edef\pgf@temp{\noexpand\pgfplotstreampoint{\noexpand\pgfqpoint{-\pgfmathresultX pt}{-\pgfmathresultY pt}}}% + \pgfutil@append@macrotomacro\pgf@tempc\pgf@temp + \edef\pgf@temp{\noexpand\pgfplotstreampoint{\noexpand\pgfqpoint{\pgfmathresultX pt}{-\pgfmathresultY pt}}}% + \pgfutil@prefix@macrotomacro\pgf@tempd\pgf@temp + \advance\c@pgf@counta by\step + \pgfutil@repeat + \pgftransformshift{\centerpoint}% + \pgfplothandlerclosedcurve + \pgfplotstreamstart + \pgfplotstreampoint{\pgfqpoint{\xradius pt}{0pt}}% east + \pgf@tempa + \pgfplotstreampoint{\pgfqpoint{0pt}{\yradius pt}}% north + \pgf@tempb + \pgfplotstreampoint{\pgfqpoint{-\xradius pt}{0pt}}% west + \pgf@tempc + \pgfplotstreampoint{\pgfqpoint{0pt}{-\yradius pt}}% south + \pgf@tempd + \pgfplotstreamend + \pgftransformshift{\centerpoint\pgf@x=-\pgf@x\pgf@y=-\pgf@y} + } + \anchorborder{% + \pgfextract@process\externalpoint{}% + \ifdim\pgf@x=0pt % catch special case x = 0 + \ifdim\pgf@y<0pt \pgf@anchor@superellipse@south\else\pgf@anchor@superellipse@north\fi + \else + \ifdim\pgf@y=0pt % catch special case y = 0 + \ifdim\pgf@x<0pt \pgf@anchor@superellipse@west\else\pgf@anchor@superellipse@east\fi + \else % both are not zero + % save original direction + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + % make both positive, we're not looking at one quadrant + \ifdim\pgf@xa<0pt \pgf@x=-\pgf@x\fi + \ifdim\pgf@ya<0pt \pgf@y=-\pgf@y\fi + % save that point again + \pgfextract@process\externalpoint{}% + % we need to do the calculations without any transformations + % since we're using plots and \pgfpointborderrectangle + \pgftransformreset + \pgfintersectionofpaths{% + % from center to point on rectangle that encompasses superellipse + \pgf@relevantforpicturesizefalse + \pgfpathmoveto{\pgfpointorigin}% + \pgfpathlineto{\pgfpointborderrectangle{\externalpoint}{\radius}}% + }{% + \pgf@relevantforpicturesizefalse + \pgf@process{\radius} + \edef\xradius{\pgf@sys@tonumber\pgf@x}% + \edef\yradius{\pgf@sys@tonumber\pgf@y}% + \let\pgf@tempa\pgfutil@empty + \c@pgf@counta=\step + \pgfutil@loop + \ifnum\c@pgf@counta<90 + \pgfmathsuperellipseXY{\the\c@pgf@counta}{\xexponent}{\yexponent}{\xradius}{\yradius}% + \edef\pgf@temp{\noexpand\pgfplotstreampoint{\noexpand\pgfqpoint{\pgfmathresultX pt}{\pgfmathresultY pt}}}% + \pgfutil@append@macrotomacro\pgf@tempa\pgf@temp + \advance\c@pgf@counta by\step + \pgfutil@repeat + % we're only using curveto since closedcurve + % messes with our other path + \pgfplothandlercurveto + \pgfplotstreamstart + \pgfplotstreampoint{\pgfqpoint{\xradius pt}{0pt}}% east + \pgf@tempa + \pgfplotstreampoint{\pgfqpoint{0pt}{\yradius pt}}% north + \pgfplotstreamend + }% + \ifnum\pgfintersectionsolutions>0 % only if a solution was found + \pgf@process{\pgfpointintersectionsolution{1}}% + \else % otherwise take the border on the rectangle (close enough?) + \pgf@process{\pgfpointborderrectangle{\externalpoint}{\radius}}% + \fi + \ifdim\pgf@xa<0pt \pgf@x=-\pgf@x\fi + \ifdim\pgf@ya<0pt \pgf@y=-\pgf@y\fi + \pgf@process{\pgfpointadd{}{\centerpoint}}% + \fi + \fi + } +} +\def\pgfutil@prefix@macrotomacro#1#2{% + \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter% + #1\expandafter\expandafter\expandafter{\expandafter#2#1}} +\endinput diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.transformations.mirror.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.transformations.mirror.code.tex new file mode 100644 index 0000000000..4d962ccb1c --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/pgflibraryext.transformations.mirror.code.tex @@ -0,0 +1,96 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +\def\pgftransformxmirror#1{ + \pgfmathparse{#1}% + \ifpgfmathunitsdeclared + \pgf@xa\pgfmathresult pt\relax + \multiply\pgf@xa2 + \pgftransformcm{-1}{0}{0}{1}{\pgfqpoint{\pgf@xa}{0pt}}% + \else + \pgftransformmirror{\pgfqpointxy{\pgfmathresult}{0}}{\pgfpointadd{\pgfqpointxy{\pgfmathresult}{0}}{\pgfqpointxy{0}{1}}}% + \fi +} +\def\pgftransformymirror#1{ + \pgfmathparse{#1}% + \ifpgfmathunitsdeclared + \pgf@ya\pgfmathresult pt\relax + \multiply\pgf@ya2 + \pgftransformcm{1}{0}{0}{-1}{\pgfqpoint{0pt}{\pgf@ya}}% + \else + \edef\pgf@marshal{\noexpand\pgftransformmirror{\noexpand\pgfqpointxy{0}{\pgfmathresult}}% + {\noexpand\pgfpointadd{\noexpand\pgfqpointxy{0}{\pgfmathresult}}{\noexpand\pgfqpointxy{1}{0}}}}% + \pgf@marshal + \fi} +\def\pgftransformmirror#1#2{% + \pgfextract@process\pgf@tempa{#1}% + \pgfpointnormalised{\pgfpointdiff{\pgf@tempa}{#2}}% + \pgf@xa=\pgf@sys@tonumber\pgf@y\pgf@x + \pgf@xb=\pgf@sys@tonumber\pgf@x\pgf@x + \pgf@yb=\pgf@sys@tonumber\pgf@y\pgf@y + \multiply\pgf@xa2 + \pgf@xc=-\pgf@yb\advance\pgf@xc\pgf@xb + \pgf@yc=-\pgf@xb\advance\pgf@yc\pgf@yb + \edef\pgf@temp{{\the\pgf@xc}{+\the\pgf@xa}{+\the\pgf@xa}{+\the\pgf@yc}}% + \expandafter\pgf@transformcm\pgf@temp{\pgf@tempa}% + \pgftransformshift{\pgfpointscale{-1}{\pgf@tempa}}% +} + +\def\pgfqtransformmirror#1{% + \pgfpointnormalised{#1}% + \pgf@xa=\pgf@sys@tonumber\pgf@y\pgf@x + \pgf@xb=\pgf@sys@tonumber\pgf@x\pgf@x + \pgf@yb=\pgf@sys@tonumber\pgf@y\pgf@y + \multiply\pgf@xa2 + \pgf@xc=-\pgf@yb\advance\pgf@xc\pgf@xb + \pgf@yc=-\pgf@xb\advance\pgf@yc\pgf@yb + \edef\pgf@temp{{\the\pgf@xc}{+\the\pgf@xa}{+\the\pgf@xa}{+\the\pgf@yc}}% + \expandafter\pgf@transformcm\pgf@temp{\pgfpointorigin}% +} + +% Using existant transformation (shift, rotate, yscale=-1, rotate back, shift back) +\def\pgftransformxMirror#1{ + \pgfmathparse{#1}% + \ifpgfmathunitsdeclared + \pgf@xa\pgfmathresult pt\relax + \multiply\pgf@xa2 + \pgftransformcm{-1}{0}{0}{1}{\pgfqpoint{\pgf@xa}{0pt}}% + \else + \pgftransformMirror{\pgfqpointxy{\pgfmathresult}{0}}{\pgfpointadd{\pgfqpointxy{\pgfmathresult}{0}}{\pgfqpointxy{0}{1}}}% + \fi +} +\def\pgftransformyMirror#1{ + \pgfmathparse{#1}% + \ifpgfmathunitsdeclared + \pgf@ya\pgfmathresult pt\relax + \multiply\pgf@ya2 + \pgftransformcm{1}{0}{0}{-1}{\pgfqpoint{0pt}{\pgf@ya}}% + \else + \edef\pgf@marshal{\noexpand\pgftransformMirror{\noexpand\pgfqpointxy{0}{\pgfmathresult}}% + {\noexpand\pgfpointadd{\noexpand\pgfqpointxy{0}{\pgfmathresult}}{\noexpand\pgfqpointxy{1}{0}}}}% + \pgf@marshal + \fi} + +\def\pgftransformMirror#1#2{% + \pgfextract@process\pgf@tempa{#1}% + \pgfmathanglebetweenpoints{\pgf@tempa}{#2}% + \let\pgf@temp\pgfmathresult + \pgftransformshift{\pgf@tempa}% + \pgftransformrotate{\pgf@temp}% + \pgftransformyscale{-1}% + \pgftransformrotate{-\pgf@temp}% + \pgftransformshift{\pgfqpointscale{-1}{\pgf@tempa}}% +} + +\def\pgfqtransformMirror#1{% + \pgfmathanglebetweenpoints{\pgfpointorigin}{#1}% + \let\pgf@temp\pgfmathresult + \pgftransformrotate{\pgf@temp}% + \pgftransformyscale{-1}% + \pgftransformrotate{-\pgf@temp}% +} +\endinput
\ No newline at end of file diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.calendar-plus.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.calendar-plus.code.tex new file mode 100644 index 0000000000..195ecf9414 --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.calendar-plus.code.tex @@ -0,0 +1,93 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% + +\usetikzlibrary{calendar} +\pgfutil@usemodule{pgfcalendar-ext} + +% Shift between days + +\def\tikz@lib@cal@xshift{\pgfkeysvalueof{/tikz/day xshift}} +\def\tikz@lib@cal@yshift{\pgfkeysvalueof{/tikz/day yshift}} +\tikzset{day xshift/.initial=3ex,day yshift/.initial=3.5ex} + +% Shift between months + +\def\tikz@lib@cal@month@xshift{\pgfkeysvalueof{/tikz/month xshift}} +\def\tikz@lib@cal@month@yshift{\pgfkeysvalueof{/tikz/month yshift}} +\tikzset{month xshift/.initial=9ex,month yshift/.initial=9ex} + +% Internal option for storing the "width" of a calendar as a number of +% days + +\def\tikz@lib@cal@width{\pgfkeysvalueof{/tikz/tikz@lib@cal@width}} +\tikzset{tikz@lib@cal@width/.initial=1} + +% Weeks + +\def\tikzweekcode{\pgfkeysvalueof{/tikz/week code}} +\def\tikzweektext{\pgfkeysvalueof{/tikz/week text}} + +\tikzset{ + week code/.initial={% + \node[every week]{\pgfkeysvalueof{/tikz/week text}};}, + week text/.initial={\%n=}, + every week/.style=, + week label left/.style={ + every week/.append style={ + anchor=base east, + xshift=-1.25*\pgfkeysvalueof{/tikz/day xshift}}, + execute before day scope=% + \ifdate{Monday, equals=\pgfcalendarbeginiso}{\tikzweekcode}{}}} + +% +% Overwriting original \tikz@lib@cal@if@else@code +% +\def\tikz@lib@cal@if@else@code#1#2#3{% + \pgfutil@addto@macro\tikz@lib@cal@ifs{\ifdate{#1}{#2}{#3}}% + \tikz@lib@cal@scanner% +} + +% +% Overwriting original \tikz@lib@cal@stop +% +\def\tikz@lib@cal@stop{% + \pgftransformshift{\tikz@node@at}% + \expandafter\pgfcalendar\expandafter{\tikz@fig@name}{\tikz@lib@cal@start}{\tikz@lib@cal@end}% + {% + \tikz@before@day% + \scope% + \tikz@atbegin@day% + \let\pgfutil@addto@macro\pgfutil@secondoftwo + \tikz@lib@cal@ifs% + \tikzdaycode% + \tikz@atend@day% + \endscope% + \tikz@after@day% + }% + \endgroup% +} + +\def\pgfutil@addto@macro#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}} + +\pgfmathdeclarefunction{weeksinmonthofyear}{3}{% #1 = first weekday, #2 = month, #3 = year + \begingroup + \pgfmathlastdayinmonthofyear@{#2}{#3}% + \pgfmathadd@{#1}{\pgfmathresult}% + \pgfmathdivide@{\pgfmathresult}{7}% + \pgfmathceil@{\pgfmathresult}% + \pgfmathint@{\pgfmathresult}% + \pgfmathsmuggle\pgfmathresult + \endgroup +} +\pgfmathdeclarefunction{lastdayinmonthofyear}{2}{% #1 = month, #2 = year + \begingroup + \pgfcalendar@getlastYMX{#2}{#1}{\pgfutil@tempcnta}% + \edef\pgfmathresult{\the\pgfutil@tempcnta}% + \pgfmathsmuggle\pgfmathresult + \endgroup +}
\ No newline at end of file diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.misc.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.misc.code.tex new file mode 100644 index 0000000000..830b3513e5 --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.misc.code.tex @@ -0,0 +1,251 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +%% full arc +%% https://tex.stackexchange.com/a/144297/16595 +%% The postfix operator R is added to PGFmath, +%% it allows the use of angular segments. +%% full arc = 10 makes it so that +%% 1R = 36° +%% 2R = 72° +%% … +%% 10R = 360° +%% Calling the full arc key with an empty value +%% makes 1R = 1° +\pgfset{full arc/.code=% + \def\pgf@temp{#1}% + \ifx\pgfutil@empty\pgf@temp + \let\pgfmath@fullarc@factor\pgfutil@empty + \else + \pgfmathsetmacro\pgfmath@fullarc@factor{360/(#1)}% + \fi,full arc=} +\pgfmathdeclareoperator{R}{full arc}{1}{postfix}{950} +\pgfmathdeclarefunction{full arc}{1}{% + \begingroup + \pgfmath@x=#1pt\relax + \ifx\pgfmath@fullarc@factor\pgfutil@empty\else + \pgfmath@x\pgfmath@fullarc@factor\pgfmath@x + \fi + \pgfmath@returnone\pgfmath@x + \endgroup} + +%% foreach +%% http://tex.stackexchange.com/a/126418/16595 +%% instead of \foreach \var in {start, start + delta, ..., end} +%% this allows to use \foreach[use int={start to end step delta}] without(!) a list in {} +%% the values start, end and delta are evaluated by PGFmath at the start of the loop. +%% In addition to use int, there's also use float. +\newif\iftikzext@pgf@foreach@no@list +\pgfqkeys{/pgf/foreach}{ + use int/.code={% + \tikzext@pgf@foreach@no@list@parse@to\pgfmathtruncatemacro#1\pgffor@stop + }, + use float/.code={% + \tikzext@pgf@foreach@no@list@parse@to\pgfmathsetmacro#1\pgffor@stop + } +} + +\def\tikzext@pgf@foreach@no@list@parse@to#1#2to#3\pgffor@stop{% + \tikzext@pgf@foreach@no@listtrue + #1\foreachStart{#2}% + \pgfutil@in@{step}{#3} + \ifpgfutil@in@ + \tikzext@pgf@foreach@no@list@parse@step{#1}#3\pgffor@stop + \else + \tikzext@pgf@foreach@no@list@parse@step{#1}#3step1\pgffor@stop + \fi + \edef\tikzext@pgf@foreach@no@list@list{\foreachStart,\foreachSecond,...,\foreachEnd}% +} +\def\tikzext@pgf@foreach@no@list@parse@step#1#2step#3\pgffor@stop{% + #1\foreachEnd{#2}% + #1\foreachSecond{\foreachStart+#3}% +} +\def\pgffor@vars{% manually extended, better etoolbox + \pgfutil@ifnextchar i{\pgffor@@vars@end}{% + \pgfutil@ifnextchar[{\pgffor@@vars@opt}{%] + \pgfutil@ifnextchar/{\pgffor@@vars@slash@gobble}{% + \iftikzext@pgf@foreach@no@list\expandafter\pgfutil@firstoftwo\else + \expandafter\pgfutil@secondoftwo\fi + {\tikzext@pgf@foreach@no@listfalse\pgffor@macro@list\tikzext@pgf@foreach@no@list@list} + {\pgffor@@vars}}}}}% + +%% Handlers +%% .pgfmath evaluates values given to keys in PGFmath before handing them over. +%% .pgfmath int truncates the result +%% .pgfmath strcat concatenates the given values +\pgfkeys{/handlers/.pgfmath/.code=\pgfmathparse{#1}\expandafter\pgfkeys@exp@call\expandafter{\pgfmathresult}} +\pgfkeys{/handlers/.pgfmath int/.code=\pgfmathint{#1}\expandafter\pgfkeys@exp@call\expandafter{\pgfmathresult}} +\pgfkeys{/handlers/.pgfmath strcat/.code=\pgfmathstrcat{#1}\expandafter\pgfkeys@exp@call\expandafter{\pgfmathresult}} + +%% http://tex.stackexchange.com/a/144187/16595 +%% key/.List={(point-1),(point-2),(point-...),(point-6)} will call +%% key=(point-1)(point-2)(point-3)(point-4)(point-5),(point-6) +\pgfkeys{/handlers/.List/.code={% + \let\pgfkeys@global@temp\pgfutil@empty + \foreach \pgfkeys@temp in{#1}{ + \ifx\pgfkeys@global@temp\pgfutil@empty + \global\let\pgfkeys@global@temp\pgfkeys@temp + \else + \expandafter\pgfutil@g@addto@macro\expandafter\pgfkeys@global@temp\expandafter + {\pgfkeys@temp}% + \fi}% + \expandafter\pgfkeys@exp@call\expandafter{\pgfkeys@global@temp}}} + +%% PGFmath +%% strrepeat("x", 5) = "xxxxx" +\pgfmathdeclarefunction{strrepeat}{2}{% + \begingroup\pgfmathint{#2}\pgfmath@count\pgfmathresult + \let\pgfmathresult\pgfutil@empty + \pgfutil@loop\ifnum\pgfmath@count>0\relax + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult#1}% + \advance\pgfmath@count-1\relax + \pgfutil@repeat\pgfmath@smuggleone\pgfmathresult\endgroup} + +%% isInString("foo", "foobar") = true (= 1) +%% isInString("boo", "foobar") = false (= 0) +\pgfmathdeclarefunction{isInString}{2}{% + \pgfutil@in@{#1}{#2}% + \ifpgfutil@in@\def\pgfmathresult{1}\else\def\pgfmathresult{0}\fi} + +%% strcat("foo", "bar") = "foobar" (can have more than two parameters) +\pgfutil@IfUndefined{pgfmathstrcat@}{ + \pgfmathdeclarefunction{strcat}{...}{% + \begingroup + \let\pgfmathresult\pgfutil@empty + \pgfmathstrcat@@#1\pgfmath@stop} + \def\pgfmathstrcat@@#1{% + \ifx\pgfmath@stop#1% + \def\pgfmath@next{\pgfmath@smuggleone\pgfmathresult\endgroup} + \else + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult#1}% + \let\pgfmath@next\pgfmathstrcat@@ + \fi + \pgfmath@next} +}{} + +% http://tex.stackexchange.com/questions/244569/bounding-lines-around-tax-nodes/244619#244619 +\pgfmathdeclarefunction{atanXY}{2}{\pgfmathatantwo@{#2}{#1}} +\pgfmathdeclarefunction{atanYX}{2}{\pgfmathatantwo@{#1}{#2}} + +%% http://tex.stackexchange.com/a/132939/16595 +\tikzset{ + @edges through/.code={{{% three braces to protect \pgfeov + \pgfutil@ifnextchar[{\pgfkeysvalueof{/tikz/@@edges through/.@cmd}} + {\pgfkeysvalueof{/tikz/@@edges through/.@cmd}[]}#1\pgfeov}}}, + @@edges through/.style args={[#1]#2}{/tikz/insert path={edge[#1] (#2) (#2)}}, + edges through/.style={/tikz/@edges through/.list={#1}}} +\tikzset{ + @edges to/.code={{{% three braces to protect \pgfeov + \pgfutil@ifnextchar[{\pgfkeysvalueof{/tikz/@@edges to/.@cmd}} + {\pgfkeysvalueof{/tikz/@@edges to/.@cmd}[]}#1\pgfeov}}}, + @@edges to/.style args={[#1]#2}{/tikz/insert path={edge[#1] (#2)}}, + edges to/.style={/tikz/@edges to/.list={#1}}} +\tikzset{ + @tos to/.code={{{% three braces to protect \pgfeov + \pgfutil@ifnextchar[{\pgfkeysvalueof{/tikz/@@tos to/.@cmd}} + {\pgfkeysvalueof{/tikz/@@tos to/.@cmd}[]}#1\pgfeov}}}, + @@tos to/.style args={[#1]#2}{/tikz/insert path={to[#1] (#2)}}, + tos to/.style={/tikz/@tos to/.list={#1}}} + + +\pgfmathdeclarefunction{distancebetween}{2}{% only coordinates/nodes + \begingroup + \pgfpointdiff{\pgfpointanchor{#1}{center}}{\pgfpointanchor{#2}{center}}% + \edef\pgfmath@temp{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}% + \expandafter\pgfmathveclen@\pgfmath@temp + \pgfmath@smuggleone\pgfmathresult + \endgroup} +\pgfmathdeclarefunction{qdistancebetween}{1}{% only coordinates/nodes + \begingroup + \pgfpointdiff{\pgfpointorigin}{\pgfpointanchor{#1}{center}}% + \edef\pgfmath@temp{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}% + \expandafter\pgfmathveclen@\pgfmath@temp + \pgfmath@smuggleone\pgfmathresult + \endgroup} + +\pgfmathdeclarefunction{qanglebetween}{1}{% + \pgfmathanglebetweenpoints{\pgfpointorigin}{\pgfpointanchor{#1}{center}}} + +\pgfmathdeclarefunction{anglebetween}{2}{% + \pgfmathanglebetweenpoints{\pgfpointanchor{#1}{center}}{\pgfpointanchor{#2}{center}}} + +\pgfmathdeclarefunction{isEmpty}{1}{% + \begingroup + \edef\pgfmath@temp{#1}% + \pgfutil@ifxempty\pgfmath@temp{\def\pgfmathresult{1}}{\def\pgfmathresult{0}}% + \pgfmath@smuggleone\pgfmathresult + \endgroup} + +\pgfqkeys{/utils}{ + if/.code n args=3{% + \pgfmathparse{#1}% + \ifdim\pgfmathresult pt=0pt + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi + {\pgfkeysalso{#3}}% + {\pgfkeysalso{#2}}}, + IF/.code args={(#1)#2}{% + \pgfmathparse{#1}% + \pgfutil@in@{else}{#2}% + \ifpgfutil@in@ + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi + {\tikzext@misc@handle@else#2\pgf@stop}{\tikzext@misc@handle@else#2else\pgf@stop}% + }, + TeX/if/.code n args={4}{% + \if#1#2\expandafter\pgfutil@firstoftwo\else\expandafter\pgfutil@secondoftwo\fi + {\pgfkeysalso{#3}}{\pgfkeysalso{#4}}% + }, + TeX/ifnum/.code n args={3}{% + \ifnum#1\relax\expandafter\pgfutil@firstoftwo\else\expandafter\pgfutil@secondoftwo\fi + {\pgfkeysalso{#2}}{\pgfkeysalso{#3}}% + }, + TeX/ifdim/.code n args={3}{% + \ifdim#1\relax\expandafter\pgfutil@firstoftwo\else\expandafter\pgfutil@secondoftwo\fi + {\pgfkeysalso{#2}}{\pgfkeysalso{#3}}% + }, + TeX/ifx/.code n args={4}{% + \ifx#1#2\relax\expandafter\pgfutil@firstoftwo\else\expandafter\pgfutil@secondoftwo\fi + {\pgfkeysalso{#3}}{\pgfkeysalso{#4}}% + }, + TeX/ifempty/.code n args={3}{% + \edef\pgfkeys@temp{#1}% + \pgfutil@ifxempty\pgfkeys@temp{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}% + }, + tex/.search also=/utils/TeX, +} +\def\tikzext@misc@handle@else#1else#2\pgf@stop{% + \ifdim\pgfmathresult pt=0pt + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi + {\pgfkeysalso{#2}}% + {\pgfkeysalso{#1}}} + +\pgfset{ + declare constant/.code={% + \let\pgfmathdeclareconstant@@@\pgfutil@empty + \pgfkeysvalueof{/pgf/declare function/execute at begin function}% + \pgfmathdeclareconstant@#1@=@;\pgf@stop + \pgfkeysvalueof{/pgf/declare function/execute at end function}% + \pgfmathdeclareconstant@@@ + }} +\def\pgfmathdeclareconstant@{% + \pgfutil@ifnextchar x\pgfmathdeclareconstant@@\pgfmathdeclareconstant@@ +} +\def\pgfmathdeclareconstant@@#1=#2;#3\pgf@stop{% + \edef\pgfmath@local@temp{#1}% + \pgfutil@ifx\pgfmath@local@temp\pgfmath@local@at{}{% + \pgfutil@g@addto@macro\pgfmathdeclareconstant@@@{\pgfmathdeclarepseudoconstant{#1}{\def\pgfmathresult{#2}}}% + \pgfmathdeclareconstant@#3\pgf@stop + }% +}
\ No newline at end of file diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.node-families.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.node-families.code.tex new file mode 100644 index 0000000000..c0ecda441a --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.node-families.code.tex @@ -0,0 +1,339 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% + +\def\tikzext@nf@align@left#1{} +\def\tikzext@nf@align@center#1{\kern.5#1} +\def\tikzext@nf@align@right#1{\kern#1} + +\pgfqkeys{/tikz/node family}{ + width/.initial=, + width/.append style={/pgf/minimum width=nf_width}, + height/.initial=, + height/.append style={/pgf/minimum height=nf_height}, + size/.code=\pgfqkeys{/tikz/node family}{width={#1},height={#1}}, + text depth/.initial=, + text height/.initial=, + text width align/.is choice, + text width align/left/.code=\let\tikzext@nf@align@action\tikzext@nf@align@left, + text width align/center/.code=\let\tikzext@nf@align@action\tikzext@nf@align@center, + text width align/right/.code=\let\tikzext@nf@align@action\tikzext@nf@align@right, + text width align=center, + text width/.initial=, + text/.code=\pgfqkeys{/tikz/node family}{text depth={#1},text height={#1},text width={#1}}, + prefix/.initial=\pgfpictureid-, +} +\tikzset{node family/.code=\pgfqkeys{/tikz/node family}{#1}} + +% #1 = family type + name +\def\tikzext@nf@save#1{% + %\errmessage{#1}% + \immediate\write\pgfutil@auxout{% + \noexpand\expandafter\noexpand\gdef\noexpand\csname tikzext@nf@#1@previous\endcsname + {\csname tikzext@nf@#1@next\endcsname}% + }% +} + +% #1 = value to set +% #2 = family type +% #3 = return dimen +\def\tikzext@nf@getandset#1#2#3{% + % what's our family's name? + #3=0pt\relax + \pgfkeysgetvalue{/tikz/node family/#2}\tikzext@nf@familyname + \pgfutil@ifxempty\tikzext@nf@familyname{% no family to deal with + }{% + \edef\tikzext@nf@familyname{\pgfkeysvalueof{/tikz/node family/prefix}\tikzext@nf@familyname}% + % we need to save the value for the next run + \pgfutil@IfUndefined{tikzext@nf@#2@\tikzext@nf@familyname @next}{% + % first time: define first value and install hook at end of picture + \expandafter\xdef\csname tikzext@nf@#2@\tikzext@nf@familyname @next\endcsname{#1}% + \edef\tikz@temp{\noexpand\tikzext@nf@save{#2@\tikzext@nf@familyname}}% + %\expandafter\AtVeryEndDocument\expandafter{\tikz@temp}% + \expandafter\pgfutil@g@addto@macro\expandafter\tikz@atend@picture\expandafter{\tikz@temp}% + }{% + \ifdim\csname tikzext@nf@#2@\tikzext@nf@familyname @next\endcsname<#1\relax + \expandafter\xdef\csname tikzext@nf@#2@\tikzext@nf@familyname @next\endcsname{#1}% + \fi + }% + \pgfutil@IfUndefined{tikzext@nf@#2@\tikzext@nf@familyname @previous}{% first run, ignore + }{% set previous value + #3=\csname tikzext@nf@#2@\tikzext@nf@familyname @previous\endcsname\relax + }% + }% +} + +\pgfdeclareshape{Rectangle}{% + \savedanchor\northeast{% + % Calculate x + % + % First, is width < minimum width? + \pgf@x=\the\wd\pgfnodeparttextbox% + \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/inner xsep}}% + \advance\pgf@x by 2\pgf@xc% + % Qrr: family width + \tikzext@nf@getandset{\the\pgf@x}{width}{\pgfutil@tempdima}% + \ifdim\pgf@x<\pgfutil@tempdima + \pgf@x=\pgfutil@tempdima + \fi + % + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% + \ifdim\pgf@x<\pgf@xb% + % yes, too small. Enlarge... + \pgf@x=\pgf@xb% + \fi% + % Now, calculate right border: .5\wd\pgfnodeparttextbox + .5 \pgf@x + outer sep + \pgf@x=.5\pgf@x% + \advance\pgf@x by.5\wd\pgfnodeparttextbox% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% + \advance\pgf@x by\pgf@xa% + % Calculate y + % + % First, is height+depth < minimum height? + \pgf@y=\ht\pgfnodeparttextbox% + \advance\pgf@y by\dp\pgfnodeparttextbox% + \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/inner ysep}}% + \advance\pgf@y by 2\pgf@yc% + % Qrr: family height + \tikzext@nf@getandset{\the\pgf@y}{height}{\pgfutil@tempdima}% + \ifdim\pgf@y<\pgfutil@tempdima + \pgf@y=\pgfutil@tempdima + \fi + % + \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}% + \ifdim\pgf@y<\pgf@yb% + % yes, too small. Enlarge... + \pgf@y=\pgf@yb% + \fi% + % Now, calculate upper border: .5\ht-.5\dp + .5 \pgf@y + outer sep + \pgf@y=.5\pgf@y% + \advance\pgf@y by-.5\dp\pgfnodeparttextbox% + \advance\pgf@y by.5\ht\pgfnodeparttextbox% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% + \advance\pgf@y by\pgf@ya% + }% + + \savedanchor\southwest{% + % Calculate x + % + % First, is width < minimum width? + \pgf@x=\wd\pgfnodeparttextbox% + \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/inner xsep}}% + \advance\pgf@x by 2\pgf@xc% + % Qrr: family width + \tikzext@nf@getandset{\the\pgf@x}{width}{\pgfutil@tempdima}% + \ifdim\pgf@x<\pgfutil@tempdima + \pgf@x=\pgfutil@tempdima + \fi + % + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% + \ifdim\pgf@x<\pgf@xb% + % yes, too small. Enlarge... + \pgf@x=\pgf@xb% + \fi% + % Now, calculate left border: .5\wd\pgfnodeparttextbox - .5 \pgf@x - outer sep + \pgf@x=-.5\pgf@x% + \advance\pgf@x by.5\wd\pgfnodeparttextbox% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% + \advance\pgf@x by-\pgf@xa% + % Calculate y + % + % First, is height+depth < minimum height? + \pgf@y=\ht\pgfnodeparttextbox% + \advance\pgf@y by\dp\pgfnodeparttextbox% + \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/inner ysep}}% + \advance\pgf@y by 2\pgf@yc% + % Qrr: family height + \tikzext@nf@getandset{\the\pgf@y}{height}{\pgfutil@tempdima}% + \ifdim\pgf@y<\pgfutil@tempdima + \pgf@y=\pgfutil@tempdima + \fi + % + \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}% + \ifdim\pgf@y<\pgf@yb% + % yes, too small. Enlarge... + \pgf@y=\pgf@yb% + \fi% + % Now, calculate upper border: .5\ht-.5\dp - .5 \pgf@y - outer sep + \pgf@y=-.5\pgf@y% + \advance\pgf@y by-.5\dp\pgfnodeparttextbox% + \advance\pgf@y by.5\ht\pgfnodeparttextbox% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% + \advance\pgf@y by-\pgf@ya% + }% + \inheritbackgroundpath[from=rectangle] + \inheritbeforebackgroundpath[from=rectangle] + \inheritbehindforegroundpath[from=rectangle] + \inheritforegroundpath[from=rectangle] + \inheritbeforeforegroundpath[from=rectangle] + \inheritanchor[from=rectangle]{center} + \inheritanchor[from=rectangle]{mid} + \inheritanchor[from=rectangle]{base} + \inheritanchor[from=rectangle]{north} + \inheritanchor[from=rectangle]{south} + \inheritanchor[from=rectangle]{west} + \inheritanchor[from=rectangle]{mid west} + \inheritanchor[from=rectangle]{base west} + \inheritanchor[from=rectangle]{north west} + \inheritanchor[from=rectangle]{south west} + \inheritanchor[from=rectangle]{east} + \inheritanchor[from=rectangle]{mid east} + \inheritanchor[from=rectangle]{base east} + \inheritanchor[from=rectangle]{north east} + \inheritanchor[from=rectangle]{south east} + \inheritanchorborder[from=rectangle] +} + +\pgfdeclareshape{Circle}{% + \savedanchor\centerpoint{% tex/generic/pgf/modules/pgfmoduleshapes.code.tex + \pgf@x=.5\wd\pgfnodeparttextbox + \pgf@y=.5\ht\pgfnodeparttextbox + \advance\pgf@y by-.5\dp\pgfnodeparttextbox + }% + \saveddimen\radius{% tex/generic/pgf/modules/pgfmoduleshapes.code.tex + % Calculate ``height radius'' + \pgf@ya=.5\ht\pgfnodeparttextbox + \advance\pgf@ya by.5\dp\pgfnodeparttextbox + \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/inner ysep}}% + \advance\pgf@ya by\pgf@yb + % Calculate ``width radius'' + \pgf@xa=.5\wd\pgfnodeparttextbox + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/inner xsep}}% + \advance\pgf@xa by\pgf@xb + % Calculate length of radius vector: + \pgf@process{\pgfpointnormalised{\pgfqpoint{\pgf@xa}{\pgf@ya}}}% + \ifdim\pgf@x>\pgf@y + \c@pgf@counta=\pgf@x + \ifnum\c@pgf@counta=0\relax + \else + \divide\c@pgf@counta by 255\relax + \pgf@xa=16\pgf@xa\relax + \divide\pgf@xa by\c@pgf@counta + \pgf@xa=16\pgf@xa\relax + \fi + \else + \c@pgf@counta=\pgf@y + \ifnum\c@pgf@counta=0\relax + \else + \divide\c@pgf@counta by 255\relax + \pgf@ya=16\pgf@ya\relax + \divide\pgf@ya by\c@pgf@counta + \pgf@xa=16\pgf@ya\relax + \fi + \fi + \pgf@x=\pgf@xa% + % Qrr: check for families + \tikzext@nf@getandset{\the\dimexpr2\pgf@x\relax}{width}{\pgfutil@tempdima}% + \tikzext@nf@getandset{\the\dimexpr2\pgf@x\relax}{height}{\pgfutil@tempdimb}% + % Qrr: and adjust like minimum width and minimum height + \ifdim\pgf@x<.5\pgfutil@tempdima + \pgf@x=.5\pgfutil@tempdima + \fi + \ifdim\pgf@x<.5\pgfutil@tempdimb + \pgf@x=.5\pgfutil@tempdimb + \fi + % If necessary, adjust radius so that the size requirements are met: + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/minimum width}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/minimum height}}% + \ifdim\pgf@x<.5\pgf@xb + \pgf@x=.5\pgf@xb + \fi + \ifdim\pgf@x<.5\pgf@yb + \pgf@x=.5\pgf@yb + \fi + % Now, add larger of outer separations. + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xb<\pgf@yb + \advance\pgf@x by\pgf@yb + \else + \advance\pgf@x by\pgf@xb + \fi + }% + \inheritbackgroundpath[from=circle] + \inheritbeforebackgroundpath[from=circle] + \inheritbehindforegroundpath[from=circle] + \inheritforegroundpath[from=circle] + \inheritbeforeforegroundpath[from=circle] + \inheritanchor[from=circle]{center} + \inheritanchor[from=circle]{mid} + \inheritanchor[from=circle]{base} + \inheritanchor[from=circle]{north} + \inheritanchor[from=circle]{south} + \inheritanchor[from=circle]{west} + \inheritanchor[from=circle]{mid west} + \inheritanchor[from=circle]{base west} + \inheritanchor[from=circle]{north west} + \inheritanchor[from=circle]{south west} + \inheritanchor[from=circle]{east} + \inheritanchor[from=circle]{mid east} + \inheritanchor[from=circle]{base east} + \inheritanchor[from=circle]{north east} + \inheritanchor[from=circle]{south east} + \inheritanchorborder[from=circle] +} + +\def\pgfutil@prefixto@macro#1#2{% + \def\pgf@temp{#2}% + \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter#1% + \expandafter\expandafter\expandafter{\expandafter\pgf@temp#1}% +} + +\pgfqkeys{/tikz/node family}{ + setup shape/.code={% + \expandafter\pgfutil@prefixto@macro\csname pgf@sh@s@#1\endcsname{% + \tikzext@nf@getandset{\the\wd\pgfnodeparttextbox}{text width}{\pgfutil@tempdima}% + \ifdim\wd\pgfnodeparttextbox<\pgfutil@tempdima + \pgfutil@tempdimb=\pgfutil@tempdima + \advance\pgfutil@tempdimb-\wd\pgfnodeparttextbox + \setbox\pgfnodeparttextbox=\hbox to \pgfutil@tempdima{\tikzext@nf@align@action\pgfutil@tempdimb\unhbox\pgfnodeparttextbox}% + \fi + \tikzext@nf@getandset{\the\dp\pgfnodeparttextbox}{text depth}{\pgfutil@tempdima}% + \ifdim\dp\pgfnodeparttextbox<\pgfutil@tempdima + \dp\pgfnodeparttextbox=\pgfutil@tempdima + \fi + \tikzext@nf@getandset{\the\ht\pgfnodeparttextbox}{text height}{\pgfutil@tempdima}% + \ifdim\ht\pgfnodeparttextbox<\pgfutil@tempdima + \ht\pgfnodeparttextbox=\pgfutil@tempdima + \fi + }% + }, + setup shape/.list={rectangle,circle,Rectangle,Circle} +} + +%% nf functions +\def\tikzext@nf@function@default{{\the\pgf@x}{\the\pgf@y}} +\def\tikzext@nf@function@default@double{{\the\dimexpr2\pgf@x\relax}{\the\dimexpr2\pgf@y\relax}} +\def\tikzext@nf@function@circle{{\the\pgf@x}{\the\pgf@x}} +\def\tikzext@nf@function@circle@double{{\the\dimexpr2\pgf@x\relax}{\the\dimexpr2\pgf@x\relax}} + +\pgfmathdeclarefunction{nf_width}{0}{% + \begingroup + \pgfutil@IfUndefined{tikzext@nf@function@\pgf@sm@shape@name}{% + \let\tikzext@nf@function\tikzext@nf@function@default + }{% + \pgfutil@IfUndefined{tikzext@nf@function@\pgf@sm@shape@name @extra}{}{\csname tikzext@nf@function@\pgf@sm@shape@name @extra\endcsname}% + \expandafter\let\expandafter\tikzext@nf@function\csname tikzext@nf@function@\pgf@sm@shape@name\endcsname + }% + \tikzext@nf@getandset{\expandafter\pgfutil@firstoftwo\tikzext@nf@function}{width}{\pgfutil@tempdima}% + \edef\pgfmathresult{\pgf@sys@tonumber\pgfutil@tempdima}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\pgfmathdeclarefunction{nf_height}{0}{% + \begingroup + \pgfutil@IfUndefined{tikzext@nf@function@\pgf@sm@shape@name}{% + \let\tikzext@nf@function\tikzext@nf@function@default + }{% + \pgfutil@IfUndefined{tikzext@nf@function@\pgf@sm@shape@name @extra}{}{\csname tikzext@nf@function@\pgf@sm@shape@name @extra\endcsname}% + \expandafter\let\expandafter\tikzext@nf@function\csname tikzext@nf@function@\pgf@sm@shape@name\endcsname + }% + \tikzext@nf@getandset{\expandafter\pgfutil@secondoftwo\tikzext@nf@function}{height}{\pgfutil@tempdima}% + \edef\pgfmathresult{\pgf@sys@tonumber\pgfutil@tempdima}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}
\ No newline at end of file diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.node-families.shapes.geometric.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.node-families.shapes.geometric.code.tex new file mode 100644 index 0000000000..58384960a8 --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.node-families.shapes.geometric.code.tex @@ -0,0 +1,38 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% + +\usetikzlibrary{ext.node-families,shapes.geometric} + +\let\tikzext@nf@function@ellipse \tikzext@nf@function@default@double +\let\tikzext@nf@function@star \tikzext@nf@function@circle +\let\tikzext@nf@function@diamond \tikzext@nf@function@default@double +\let\tikzext@nf@function@star \tikzext@nf@function@circle@double +\expandafter\let\csname tikzext@nf@function@regular polygon\endcsname + \tikzext@nf@function@circle@double +\let\tikzext@nf@function@trapezium\tikzext@nf@function@default@double +\def\tikzext@nf@function@semicircle {{\the\dimexpr2\pgf@x\relax}{\the\pgf@x}} +\expandafter\def\csname tikzext@nf@function@isosceles triangle\endcsname + {{\the\dimexpr2\pgf@ya\relax}{\the\pgf@xa}} +\def\tikzext@nf@function@kite {{\the\dimexpr2\pgf@xa\relax}{\the\dimexpr\pgf@ya+\pgf@yb\relax}} +\def\tikzext@nf@function@dart {{\the\dimexpr2\pgf@ya\relax}{\the\pgf@xb}} +\expandafter\def\csname tikzext@nf@function@circular sector\endcsname{{\the\pgf@xc}{\the\pgf@xa}} +\def\tikzext@nf@function@cylinder{{\the\dimexpr2\pgfutil@tempdimb\relax}{\the\pgf@x}} + +\tikzset{node family/setup shape/.list={ + ellipse, + star, + diamond, + regular polygon, + trapezium, + semicircle, + isosceles triangle, + kite, + dart, + circular sector, + cylinder +}}
\ No newline at end of file diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.paths.arcto.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.paths.arcto.code.tex new file mode 100644 index 0000000000..c75f31b60a --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.paths.arcto.code.tex @@ -0,0 +1,326 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +\tikzset{ + arc to/.code=\pgfqkeys{/tikz/arc to}{#1}, + arc to={ + counter clockwise/.code=\pgfkeyssetvalue{/tikz/arc to/ccw flag}{1}, + clockwise/.code=\pgfkeyssetvalue{/tikz/arc to/ccw flag}{0}, + x radius/.code=\pgfkeyssetvalue{/tikz/x radius}{#1}, + y radius/.code=\pgfkeyssetvalue{/tikz/y radius}{#1}, + radius/.code=\pgfkeyssetvalue{/tikz/x radius}{#1}\pgfkeyssetvalue{/tikz/y radius}{#1}, + large/.code=\pgfkeyssetvalue{/tikz/arc to/large flag}{1}, + small/.code=\pgfkeyssetvalue{/tikz/arc to/large flag}{0}, + % defaults + rotate/.initial=0, counter clockwise, small, + counter clockwise/.value forbidden, + clockwise/.value forbidden, + large/.value forbidden, + small/.value forbidden}} +\def\tikz@arcA rc{\pgfutil@ifnextchar t% + {\tikz@flush@moveto\expandafter\expandafter\expandafter\tikz@arcB@cont\expandafter\pgfutil@gobble\pgfutil@gobble} + {\tikz@flush@moveto\tikz@arc@cont}} +\def\tikz@arcB@cont{% + \pgfutil@ifnextchar[\tikz@@do@arcB{ + \advance\tikz@expandcount by -10\relax% go down quickly + \ifnum\tikz@expandcount<0\relax% + \def\@next{\tikz@@do@arcB[]}% + \else% + \def\@next{\expandafter\tikz@arcB@cont}% + \fi% + \@next}}% +\def\tikz@@do@arcB[#1]{% + \def\tikz@arcB@options{#1}% + \tikz@do@@arcB} +\def\tikz@do@@arcB{% + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@do@@arcB} + {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@do@@arcB} + {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@do@@arcB} + {\tikz@scan@one@point\tikz@do@arcB}}}} + +\def\tikz@do@arcB#1{% + \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}} + \tikz@make@last@position{#1}% + \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \iftikz@shapeborder + \edef\tikz@moveto@waiting{\tikz@shapeborder@name}% + \fi + \begingroup + \tikzset{every arc/.try,every arc to/.try,arc to/.expand once=\tikz@arcB@options}% + \pgfmathsetmacro\tikz@arc@x{\pgfkeysvalueof{/tikz/x radius}}% + \ifpgfmathunitsdeclared + \pgfmathsetmacro\tikz@arc@y{\pgfkeysvalueof{/tikz/y radius}}% + \ifpgfmathunitsdeclared + \tikzext@pgfpatharcto{\tikz@arc@x pt}{\tikz@arc@y pt} + {\pgfkeysvalueof{/tikz/arc to/rotate}}{\pgfkeysvalueof{/tikz/arc to/large flag}} + {\pgfkeysvalueof{/tikz/arc to/ccw flag}}{#1}% + \else + \tikzerror{You cannot mix dimensions and dimension values in an arc}% + \fi + \else + \pgfmathsetmacro\tikz@arc@y{\pgfkeysvalueof{/tikz/y radius}}% + \ifpgfmathunitsdeclared + \tikzerror{You cannot mix dimensions and dimension values in an arc}% + \else + \pgf@process{\pgfpointxy{\tikz@arc@x}{0}}% + \pgfmathveclen@{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}% + \let\tikz@arc@x\pgfmathresult + \pgf@process{\pgfpointxy{0}{\tikz@arc@y}}% + \pgfmathveclen@{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}% + \let\tikz@arc@y\pgfmathresult + \tikzext@pgfpatharcto{+\tikz@arc@x pt}{+\tikz@arc@y pt} + {\pgfkeysvalueof{/tikz/arc to/rotate}}{\pgfkeysvalueof{/tikz/arc to/large flag}} + {\pgfkeysvalueof{/tikz/arc to/ccw flag}}{#1}% + \fi + \fi + \endgroup + % check whether \pgf@marshall starts with \pgfpathlineto + \pgfutil@ifxempty\pgf@marshal{}{% + \edef\tikz@temp{\expandafter\expandafter\expandafter\noexpand\expandafter\pgfutil@firstgobblerest\pgf@marshal\relax}% + \expandafter\let\expandafter\tikz@temp\tikz@temp + \pgfutil@ifx\tikz@temp\pgfpathlineto{}{% + % getting rid of \pgfpatharcaxes inside \pgf@marshal + \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@marshal + \expandafter\expandafter\expandafter{\expandafter\pgfutil@gobble\pgf@marshal}% + % extracting the other four values needed for the timer + \edef\tikz@timer@start@angle{\expandafter\pgfutil@firstoffour\pgf@marshal}% + \edef\tikz@timer@end@angle{\expandafter\pgfutil@secondoffour\pgf@marshal}% + \pgfextract@process\tikz@timer@zero@axis{\expandafter\pgfutil@thirdoffour\pgf@marshal}% + \pgfextract@process\tikz@timer@ninety@axis{\expandafter\pgfutil@fourthoffour\pgf@marshal}% + % + \let\tikz@timer=\tikz@timer@arc + }% + }% + \tikz@scan@next@command +} +\def\pgfutil@firstoffour#1#2#3#4{#1} +\def\pgfutil@secondoffour#1#2#3#4{#2} +\def\pgfutil@thirdoffour#1#2#3#4{#3} +\def\pgfutil@fourthoffour#1#2#3#4{#4} +\def\pgfutil@firstgobblerest#1#2\relax{#1} + +% original from pgfcorepathconstruct.code.tex +\def\tikzext@pgfpatharcto#1#2#3#4#5#6{% + {% + % The following code is based on the transformation described in svg + % 1.1 specification Section F.6.5 + % + % Step 1: store the simple parameters (xa=x1 since TeX does not + % allow numbers in names) + % + \pgfmathsetmacro\pgf@arcto@rx{abs(#1)}% + \pgfmathsetmacro\pgf@arcto@ry{abs(#2)}% + \ifdim\pgf@arcto@rx pt=0pt% special rule: zero radius=straight line + \gdef\pgf@marshal{\pgfpathlineto{#6}}% + \else + \ifdim\pgf@arcto@ry pt=0pt% special rule: zero radius=straight line + \gdef\pgf@marshal{\pgfpathlineto{#6}}% + \else + \pgfmathsetmacro\pgf@arcto@phi{#3}% + \pgfmathsetmacro\pgf@arcto@fA{#4}% + \ifdim\pgf@arcto@fA pt=0pt + \else + \pgfmathsetmacro\pgf@arcto@fA{1.0}% Special rule: every non-zero value is 1. + \fi + \pgfmathsetmacro\pgf@arcto@fS{#5}% + \ifdim\pgf@arcto@fS pt=0pt + \else + \pgfmathsetmacro\pgf@arcto@fS{1.0}% Special rule: every non-zero value is 1. + \fi + \pgf@process{#6}% + \edef\pgf@arcto@xb{\the\pgf@x}% + \edef\pgf@arcto@yb{\the\pgf@y}% + % + % Step 2: x1,y1 is more complicated to compute: It is given by lastx + % and lasty, but these are transformed coordinates, we need the + % untransformed ones. So, we inverse the transformation (arghh...) + % + \pgftransforminvert% + \pgf@process{\pgfpointtransformed{\pgfqpoint{\pgf@path@lastx}{\pgf@path@lasty}}}% + \edef\pgf@arcto@xa{\the\pgf@x}% + \edef\pgf@arcto@ya{\the\pgf@y}% + \edef\pgf@temp@a{\pgf@arcto@xa,\pgf@arcto@ya}% + \edef\pgf@temp@b{\pgf@arcto@xb,\pgf@arcto@yb}% + \ifx\pgf@temp@a\pgf@temp@b% special rule: skip! + \global\let\pgf@marshal\pgfutil@empty + \else + % + % Ok, now we got all the parameters setup. Now comes the + % computation... + % + % + % Step 3: Start with a new coordinate system and rotate everything + % by the negated phi. + % + \pgftransformreset + \pgftransformrotate{-\pgf@arcto@phi}% + % Ok, using \pgfpointtransformed we now get transformed points... + % + % Step 4: Compute x1' and y1' (xaprime and yaprime) + % + \pgf@process{% + \pgfpointtransformed{\pgfpointscale{.5}{\pgfpointdiff + {\pgfqpoint{\pgf@arcto@xb}{\pgf@arcto@yb}} + {\pgfqpoint{\pgf@arcto@xa}{\pgf@arcto@ya}}% + }% + }% + }% + \edef\pgf@arcto@xaprime{\pgf@sys@tonumber\pgf@x}% + \edef\pgf@arcto@yaprime{\pgf@sys@tonumber\pgf@y}% + % + % Compute Lambda + % + \pgfmathsetmacro\pgf@arcto@frac@x{\pgf@arcto@xaprime/\pgf@arcto@rx}% + \pgfmathsetmacro\pgf@arcto@frac@y{\pgf@arcto@yaprime/\pgf@arcto@ry}% + \pgfmathsetmacro\pgf@arcto@lambda{ + \pgf@arcto@frac@x*\pgf@arcto@frac@x+\pgf@arcto@frac@y*\pgf@arcto@frac@y + }% + \ifdim\pgf@arcto@lambda pt>1pt + \pgfmathsetmacro\pgf@arcto@sqrt@lambda{sqrt(\pgf@arcto@lambda)}% + \pgfmathsetmacro\pgf@arcto@rx{\pgf@arcto@sqrt@lambda*\pgf@arcto@rx}% + \pgfmathsetmacro\pgf@arcto@ry{\pgf@arcto@sqrt@lambda*\pgf@arcto@ry}% + \fi + % + % Do some scaling + % + \pgfmathsetmacro\pgf@arcto@xaprime@abs{abs(\pgf@arcto@xaprime)}% + \pgfmathsetmacro\pgf@arcto@yaprime@abs{abs(\pgf@arcto@yaprime)}% + \pgfmathmax@{\pgf@arcto@rx,\pgf@arcto@ry,\pgf@arcto@xaprime@abs,\pgf@arcto@yaprime@abs}% + \pgfmathsetmacro\pgf@arcto@scaling{20/\pgfmathresult}% + \pgfmathsetmacro\pgf@arcto@rx@scaled{\pgf@arcto@scaling*\pgf@arcto@rx}% + \pgfmathsetmacro\pgf@arcto@ry@scaled{\pgf@arcto@scaling*\pgf@arcto@ry}% + \pgfmathsetmacro\pgf@arcto@xaprime@scaled{\pgf@arcto@scaling*\pgf@arcto@xaprime}% + \pgfmathsetmacro\pgf@arcto@yaprime@scaled{\pgf@arcto@scaling*\pgf@arcto@yaprime}% + % + % Step 5: Now comes the messy computation of c1' and c2'. + % + \ifdim\pgf@arcto@rx pt>\pgf@arcto@ry pt + \pgfmathsetmacro\pgf@arcto@rx@over@ry{\pgf@arcto@rx/\pgf@arcto@ry}% + \pgfmathsetmacro\pgf@arcto@ry@over@rx{\pgf@arcto@ry/\pgf@arcto@rx}% + \pgfmathsetmacro\pgf@arcto@temp{\pgf@arcto@ry@over@rx*\pgf@arcto@xaprime@scaled}% + \pgfmathsetmacro\pgf@arcto@numerator{ + \pgf@arcto@ry@scaled*\pgf@arcto@ry@scaled- + \pgf@arcto@yaprime@scaled*\pgf@arcto@yaprime@scaled- + \pgf@arcto@temp*\pgf@arcto@temp + }% + \pgfmathsetmacro\pgf@arcto@denominator{ + \pgf@arcto@yaprime@scaled*\pgf@arcto@yaprime@scaled+ + \pgf@arcto@temp*\pgf@arcto@temp + }% + \else + \pgfmathsetmacro\pgf@arcto@rx@over@ry{\pgf@arcto@rx/\pgf@arcto@ry}% + \pgfmathsetmacro\pgf@arcto@ry@over@rx{\pgf@arcto@ry/\pgf@arcto@rx}% + \pgfmathsetmacro\pgf@arcto@temp{\pgf@arcto@rx@over@ry*\pgf@arcto@yaprime@scaled}% + \pgfmathsetmacro\pgf@arcto@numerator{ + \pgf@arcto@rx@scaled*\pgf@arcto@rx@scaled- + \pgf@arcto@xaprime@scaled*\pgf@arcto@xaprime@scaled- + \pgf@arcto@temp*\pgf@arcto@temp + }% + \pgfmathsetmacro\pgf@arcto@denominator{ + \pgf@arcto@xaprime@scaled*\pgf@arcto@xaprime@scaled+ + \pgf@arcto@temp*\pgf@arcto@temp + }% + \fi + \pgfmathsetmacro\pgf@arcto@frac{ + \pgf@arcto@numerator/\pgf@arcto@denominator + }% + \ifdim\pgf@arcto@frac pt<0pt + \pgfmathsetmacro\pgf@arcto@factor{0}% + \else + \pgfmathsetmacro\pgf@arcto@factor{sqrt(\pgf@arcto@frac)}% + \fi + \ifx\pgf@arcto@fA\pgf@arcto@fS + \pgfmathsetmacro\pgf@arcto@factor{-\pgf@arcto@factor}% + \fi + \pgfmathsetmacro\pgf@arcto@cxprime{ + \pgf@arcto@factor*\pgf@arcto@rx@over@ry*\pgf@arcto@yaprime + }% + \pgfmathsetmacro\pgf@arcto@cyprime{ + -\pgf@arcto@factor*\pgf@arcto@ry@over@rx*\pgf@arcto@xaprime + }% + % + % Step 6: Ok, now compute cx,cy + % + \pgftransformreset + \pgftransformrotate{\pgf@arcto@phi}% + \pgf@process{% + \pgfpointtransformed{\pgfqpoint{\pgf@arcto@cxprime pt}{\pgf@arcto@cyprime pt}}% + }% + \edef\pgf@arcto@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \pgf@process{\pgfpointadd{\pgf@arcto@temp}{% + \pgfpointscale{.5}{% + \pgfpointadd + {\pgfqpoint{\pgf@arcto@xa}{\pgf@arcto@ya}} + {\pgfqpoint{\pgf@arcto@xb}{\pgf@arcto@yb}}}% + }% + }% + \edef\pgf@arcto@cx{\the\pgf@x}% + \edef\pgf@arcto@cy{\the\pgf@y}% + % + % Step 7: Compute start angle: + % + \pgfmathsetmacro\pgf@arcto@vec@x{(\pgf@arcto@xaprime-\pgf@arcto@cxprime)/\pgf@arcto@rx}% + \pgfmathsetmacro\pgf@arcto@vec@y{(\pgf@arcto@yaprime-\pgf@arcto@cyprime)/\pgf@arcto@ry}% + \pgfmathsetmacro\pgf@arcto@denominator{veclen(\pgf@arcto@vec@x,\pgf@arcto@vec@y)}% + \pgfmathsetmacro\pgf@arcto@frac{\pgf@arcto@vec@x/\pgf@arcto@denominator}% + \pgfmathsetmacro\pgf@arcto@theta@start{acos(\pgf@arcto@frac)}% + \ifdim\pgf@arcto@vec@y pt<0pt + \pgfmathsetmacro\pgf@arcto@theta@start{-\pgf@arcto@theta@start}% + \fi + % + % Step 8: Compute end angle: + % + \pgfmathsetmacro\pgf@arcto@vec@x{(-\pgf@arcto@xaprime-\pgf@arcto@cxprime)/\pgf@arcto@rx}% + \pgfmathsetmacro\pgf@arcto@vec@y{(-\pgf@arcto@yaprime-\pgf@arcto@cyprime)/\pgf@arcto@ry}% + \pgfmathsetmacro\pgf@arcto@denominator{veclen(\pgf@arcto@vec@x,\pgf@arcto@vec@y)}% + \pgfmathsetmacro\pgf@arcto@frac{\pgf@arcto@vec@x/\pgf@arcto@denominator}% + \pgfmathsetmacro\pgf@arcto@theta@end{acos(\pgf@arcto@frac)}% + \ifdim\pgf@arcto@vec@y pt<0pt + \pgfmathsetmacro\pgf@arcto@theta@end{-\pgf@arcto@theta@end}% + \fi + \pgfmathsetmacro\pgf@arcto@delta@theta{abs(\pgf@arcto@theta@start-\pgf@arcto@theta@end)}% + \ifdim\pgf@arcto@fA pt=0pt + \ifdim\pgf@arcto@delta@theta pt>180pt + % Ok, we need to adjust the angle! + \ifdim\pgf@arcto@theta@end pt>\pgf@arcto@theta@start pt + \pgfmathsetmacro\pgf@arcto@theta@end{\pgf@arcto@theta@end-360}% + \else + \pgfmathsetmacro\pgf@arcto@theta@end{\pgf@arcto@theta@end+360}% + \fi + \fi + \else + \ifdim\pgf@arcto@delta@theta pt<180pt + % Ok, we need to adjust the angle! + \ifdim\pgf@arcto@theta@end pt>\pgf@arcto@theta@start pt + \pgfmathsetmacro\pgf@arcto@theta@end{\pgf@arcto@theta@end-360}% + \else + \pgfmathsetmacro\pgf@arcto@theta@end{\pgf@arcto@theta@end+360}% + \fi + \fi + \fi + % Qrr: + % make sure direction is properly followed + \ifdim\pgf@arcto@fS pt=1pt + % counter clockwise + \ifdim\pgf@arcto@theta@end pt<\pgf@arcto@theta@start path + \pgfmathsetmacro\pgf@arcto@theta@end{\pgf@arcto@theta@end+360}% + \fi + \else + % clockwise + \ifdim\pgf@arcto@theta@end pt>\pgf@arcto@theta@start path + \pgfmathsetmacro\pgf@arcto@theta@end{\pgf@arcto@theta@end-360}% + \fi + \fi + \xdef\pgf@marshal{\noexpand + \pgfpatharcaxes{\pgf@arcto@theta@start}{\pgf@arcto@theta@end} + {\noexpand\pgfpointpolar{\pgf@arcto@phi}{\pgf@arcto@rx}} + {\noexpand\pgfpointpolar{\pgf@arcto@phi+90}{\pgf@arcto@ry}}% + }% + \fi\fi\fi + }% + \pgf@marshal +}
\ No newline at end of file diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.paths.ortho.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.paths.ortho.code.tex new file mode 100644 index 0000000000..9740c39cc2 --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.paths.ortho.code.tex @@ -0,0 +1,692 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% + +%% For the operators r-lr, r-rl, r-ud and r-du we need to check after TikZ found r +\let\tikz@orig@rect\tikz@rect +\def\tikz@rect{\pgfutil@ifnextchar e\tikz@orig@rect\tikzext@tikz@r} +\def\tikzext@tikz@r -{% + \pgfutil@ifnextchar l\tikzext@tikz@lr@lineto{% + \pgfutil@ifnextchar r\tikzext@tikz@rl@lineto{% + \pgfutil@ifnextchar u\tikzext@tikz@ud@lineto{% + \pgfutil@ifnextchar d\tikzext@tikz@du@lineto\tikz@expand + }% + }% + }% +} +%% For the operator |-| we need to check after TikZ found |- +\let\tikz@orig@vh@lineto@next\tikz@vh@lineto@next +\def\tikz@vh@lineto@next{% + \pgfutil@ifnextchar|{\expandafter\tikzext@tikz@vhv@lineto\pgfutil@gobble}% + {\pgfutil@ifnextchar\tikz@activebar{\expandafter\tikzext@tikz@vhv@lineto\pgfutil@gobble}% + {\tikz@orig@vh@lineto@next}}} +%% For the operator -|- we need to check after TikZ found -| +\let\tikz@orig@hv@lineto\tikz@hv@lineto +\def\tikz@hv@lineto{% + \pgfutil@ifnextchar-{\expandafter\tikzext@tikz@hvh@lineto\pgfutil@gobble}% + {\tikz@orig@hv@lineto}} + +%% |-|[<opts>] and -|-[<opts>] are allowed +\def\tikzext@tikz@vhv@lineto{\pgfutil@ifnextchar[{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@vhv@lineto@next}{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@vhv@lineto@next[]}} +\def\tikzext@tikz@hvh@lineto{\pgfutil@ifnextchar[{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@hvh@lineto@next}{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@hvh@lineto@next[]}} + +%% r-rl[<opts>], r-lr[<opts>], etc. +\def\tikzext@tikz@rl@lineto rl{\pgfutil@ifnextchar[{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@rl@lineto@next}{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@rl@lineto@next[]}} +\def\tikzext@tikz@lr@lineto lr{\pgfutil@ifnextchar[{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@lr@lineto@next}{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@lr@lineto@next[]}} +\def\tikzext@tikz@du@lineto du{\pgfutil@ifnextchar[{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@du@lineto@next}{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@du@lineto@next[]}} +\def\tikzext@tikz@ud@lineto ud{\pgfutil@ifnextchar[{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@ud@lineto@next}{\tikzext@tikz@collect@hvvh@options\tikzext@tikz@ud@lineto@next[]}} + +%% TikZ interjects are done, the rest is independent: + +\newlength\tikzext@tikz@udlr@distance +\newlength\tikzext@tikz@hvvh@distance +\newif\iftikzext@tikz@hvvh@middle % checks whether spacing = 0 was selected +\newif\iftikzext@tikz@hvvh@fromcenter +\newif\iftikzext@ortho@preflush +\tikzext@ortho@preflushtrue + +%%% HVVH/UDLR +\tikzset{% + ortho/.code=\pgfqkeys{/tikz/ortho}{#1}, + hvvh/.code=\pgfqkeys{/tikz/ortho}{#1},% + udlr/.code=\pgfqkeys{/tikz/ortho}{#1},% + ortho/.search also=/tikz, + ortho/middle 0 to 1/.style={/tikz/ortho/spacing=0},% + ortho/from center/.is if=tikzext@tikz@hvvh@fromcenter,% + ortho/spacing/.code=% spacing = 0 means that the middle part are the pos-itions 0 to 1, + % the first part is -1 to 0, the last part is to 2 + \pgfmathint{#1}\let\tikzext@tikz@hvvh@timing@parts\pgfmathresult% in case they are calculations to be done + \ifcase\tikzext@tikz@hvvh@timing@parts\relax + \tikzext@tikz@hvvh@middletrue + \def\tikzext@tikz@hvvh@timing@parts{1}% + \def\tikzext@tikz@hvvh@timing@first{0}% + \def\tikzext@tikz@hvvh@timing@last{1}% + \def\tikzext@tikz@hvvh@timing@subtr{0}% + \def\tikzext@tikz@hvvh@timing@factor{1}% + \else % in all other cases n > 0 the kinks are at pos = 1/n and (n - 1)/n + \tikzext@tikz@hvvh@middlefalse + \pgfmathreciprocal{#1}\let\tikzext@tikz@hvvh@timing@first\pgfmathresult + \pgfmathsetmacro\tikzext@tikz@hvvh@timing@last{1-\pgfmathresult}% + \pgfmathreciprocal{#1-2}% + \let\tikzext@tikz@hvvh@timing@subtr\pgfmathresult + \pgfmathsetmacro\tikzext@tikz@hvvh@timing@factor{1+2*\pgfmathresult}% + \fi,% + ortho/ratio/.code=\pgfmathsetmacro\tikzext@tikz@hvvh@ratio{#1},% + % TODO: not possible to do distance in TikZ coordinate system + ortho/distance/.code=\pgfmathsetlength\tikzext@tikz@hvvh@distance{#1}\let\tikzext@tikz@hvvh@ratio\pgfutil@empty,% + ortho/udlr distance/.style={% + /tikz/ortho/ud distance={#1},% + /tikz/ortho/du distance={#1},% + /tikz/ortho/lr distance={#1},% + /tikz/ortho/rl distance={#1}},% + ortho/ud distance/.initial=+.5cm,% + ortho/du distance/.initial=+.5cm,% + ortho/lr distance/.initial=+.5cm,% + ortho/rl distance/.initial=+.5cm,% + ortho/ratio=.5,% default value + ortho/spacing=4,% default value +}% + +%BEGIN_FOLD Timer +\def\tikz@timer@hvhline{% + \pgf@process{\tikz@timer@start}\pgf@ya\pgf@y + \pgf@process{\tikz@timer@end}\pgf@yc\pgf@y + \pgf@process{\tikz@timer@middle}\pgf@xb\tikz@time pt% + \ifdim\tikz@time pt<\tikzext@tikz@hvvh@timing@first pt% first quarter + \iftikzext@tikz@hvvh@middle + \advance\pgf@xb1pt% + \else + \pgf@xb\tikzext@tikz@hvvh@timing@parts\pgf@xb + \fi + \edef\tikz@marshal{\noexpand\pgftransformlineattime{\pgf@sys@tonumber{\pgf@xb}}{\noexpand\tikz@timer@start}{% + \noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@ya}}}% + \else + \ifdim\tikz@time pt>\tikzext@tikz@hvvh@timing@last pt% last quarter + \iftikzext@tikz@hvvh@middle + \advance\pgf@xb-1pt% + \else + \pgf@xb\tikzext@tikz@hvvh@timing@parts\pgf@xb + \fi + \advance\pgf@xb\dimexpr-\tikzext@tikz@hvvh@timing@parts pt+1pt\relax% + \edef\tikz@marshal{\noexpand\pgftransformlineattime{\pgf@sys@tonumber{\pgf@xb}}% + {\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@yc}}{\noexpand\tikz@timer@end}}% + \else% middle half + \pgf@xb\tikzext@tikz@hvvh@timing@factor\pgf@xb% + \advance\pgf@xb-\tikzext@tikz@hvvh@timing@subtr pt% + \edef\tikz@marshal{\noexpand\pgftransformlineattime{\pgf@sys@tonumber{\pgf@xb}}% + {\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@ya}}{\noexpand\tikz@timer@middle}}% + \fi\fi\tikz@marshal} +\def\tikz@timer@vhvline{% + \pgf@process{\tikz@timer@start}\pgf@xa\pgf@x + \pgf@process{\tikz@timer@end}\pgf@xc\pgf@x + \pgf@process{\tikz@timer@middle}\pgf@xb\tikz@time pt% + \ifdim\tikz@time pt<\tikzext@tikz@hvvh@timing@first pt% first quarter + \iftikzext@tikz@hvvh@middle + \advance\pgf@xb1pt% + \else + \pgf@xb\tikzext@tikz@hvvh@timing@parts\pgf@xb + \fi + \edef\tikz@marshal{\noexpand\pgftransformlineattime{\pgf@sys@tonumber{\pgf@xb}}{\noexpand\tikz@timer@start}{% + \noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@y}}}% + \else + \ifdim\tikz@time pt>\tikzext@tikz@hvvh@timing@last pt% last quarter + \iftikzext@tikz@hvvh@middle + \advance\pgf@xb-1pt% + \else + \pgf@xb\tikzext@tikz@hvvh@timing@parts\pgf@xb + \fi + \advance\pgf@xb by\dimexpr-\tikzext@tikz@hvvh@timing@parts pt+1pt\relax% + \edef\tikz@marshal{\noexpand\pgftransformlineattime{\pgf@sys@tonumber{\pgf@xb}}% + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@y}}{\noexpand\tikz@timer@end}}% + \else% middle half + \pgf@xb=\tikzext@tikz@hvvh@timing@factor\pgf@xb + \advance\pgf@xb by-\tikzext@tikz@hvvh@timing@subtr pt% + \edef\tikz@marshal{\noexpand\pgftransformlineattime{\pgf@sys@tonumber{\pgf@xb}}% + {\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@y}}{\noexpand\tikz@timer@middle}}% + \fi\fi\tikz@marshal}% + +%% collect options and nodes, coordinates and pics onpath +\let\tikz@hvvh@currentoption\pgfutil@empty +\def\tikzext@tikz@collect@hvvh@options#1[#2]{\edef\tikz@hvvh@currentoption{#2}#1} +\def\tikzext@tikz@hvh@lineto@next{% + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@tikz@hvh@lineto@next} + {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@tikz@hvh@lineto@next}% + {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@tikz@hvh@lineto@next}{\tikz@scan@one@point\tikzext@tikz@@hvh@lineto}}}}% +\def\tikzext@tikz@vhv@lineto@next{% + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@tikz@vhv@lineto@next} + {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@tikz@vhv@lineto@next}% + {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@tikz@vhv@lineto@next}{\tikz@scan@one@point\tikzext@tikz@@vhv@lineto}}}}% +\def\tikzext@tikz@ud@lineto@next{% + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@tikz@ud@lineto@next} + {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@tikz@ud@lineto@next} + {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@tikz@ud@lineto@next}{\tikz@scan@one@point\tikzext@tikz@@ud@lineto}}}}% +\def\tikzext@tikz@du@lineto@next{% + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@tikz@du@lineto@next} + {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@tikz@du@lineto@next} + {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@tikz@du@lineto@next}{\tikz@scan@one@point\tikzext@tikz@@du@lineto}}}}% +\def\tikzext@tikz@lr@lineto@next{% + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@tikz@lr@lineto@next} + {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@tikz@lr@lineto@next} + {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@tikz@lr@lineto@next}{\tikz@scan@one@point\tikzext@tikz@@lr@lineto}}}}% +\def\tikzext@tikz@rl@lineto@next{% + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@tikz@rl@lineto@next} + {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@tikz@rl@lineto@next} + {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@tikz@rl@lineto@next}{\tikz@scan@one@point\tikzext@tikz@@rl@lineto}}}}% + +\def\tikz@do@hvvh#1#2#3#4#5{% +% #1 = first kink +% #2 = second kink +% #3 = end +% #4 = timer +% #5 = tikz@shapeborder@name + \pgfpathlineto{#1}% + \pgfpathlineto{#2}% + \pgfpathlineto{#3}% + \def\tikz@timer@middle{#2}% + \def\tikz@timer@end{#3}% + \let\tikz@timer#4 + \edef\pgf@temp{#5}% + \ifx\pgf@temp\pgfutil@empty + \let\tikz@moveto@waiting\relax + \else + \let\tikz@moveto@waiting\pgf@temp + \fi + \tikz@scan@next@command}% + +%% -|- operator +\def\tikzext@tikz@@hvh@lineto#1{% + \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \pgf@xb=\tikz@lastx + \pgf@xc=\tikz@lastx + \pgf@yc=\tikz@lasty + \tikz@make@last@position{#1}% + \tikz@flush@moveto@toward{\pgfqpoint{\tikz@lastx}{\pgf@yc}}\pgf@xc\pgf@yc + \begingroup + \pgfqkeys{/tikz/ortho}{/tikz/style/.expand once=\tikz@hvvh@currentoption}% + \iftikz@shapeborder + \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\pgf@xb}{\tikz@lasty}}}% + \iftikzext@tikz@hvvh@fromcenter + \pgf@xc\pgf@xb + \fi + \pgfutil@ifxempty\tikzext@tikz@hvvh@ratio{% + \ifdim\tikzext@tikz@hvvh@distance<0pt\relax + \iftikzext@tikz@hvvh@fromcenter + \pgf@xc\tikz@lastx + \else + \pgf@xc\pgf@x + \fi + \fi + \ifdim\pgf@xb>\tikz@lastx + \tikzext@tikz@hvvh@distance-\tikzext@tikz@hvvh@distance + \fi + }{% + \iftikzext@tikz@hvvh@fromcenter + \tikzext@tikz@hvvh@distance\tikz@lastx + \else + \tikzext@tikz@hvvh@distance\pgf@x + \fi + \advance\tikzext@tikz@hvvh@distance-\pgf@xc + \tikzext@tikz@hvvh@distance\tikzext@tikz@hvvh@ratio\tikzext@tikz@hvvh@distance + }% + \advance\pgf@xc\tikzext@tikz@hvvh@distance + \edef\pgf@tempa{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + \edef\pgf@tempb{\noexpand\pgfqpoint{\the\pgf@xc}{\the\tikz@lasty}}% + \edef\pgf@temp{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \else + \let\tikz@shapeborder@name\pgfutil@empty + \iftikzext@tikz@hvvh@fromcenter + \pgf@xc\pgf@xb + \fi + \pgfutil@ifxempty\tikzext@tikz@hvvh@ratio{% + \ifdim\tikzext@tikz@hvvh@distance<0pt\relax + \pgf@xc\tikz@lastx + \fi + \ifdim\pgf@xb>\tikz@lastx + \tikzext@tikz@hvvh@distance-\tikzext@tikz@hvvh@distance + \fi + }{% + \tikzext@tikz@hvvh@distance\tikz@lastx + \advance\tikzext@tikz@hvvh@distance-\pgf@xc + \tikzext@tikz@hvvh@distance\tikzext@tikz@hvvh@ratio\tikzext@tikz@hvvh@distance + }% + \advance\pgf@xc\tikzext@tikz@hvvh@distance + \edef\pgf@tempa{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + \edef\pgf@tempb{\noexpand\pgfqpoint{\the\pgf@xc}{\the\tikz@lasty}}% + \edef\pgf@temp{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \fi% + \xdef\pgf@marshal{% + \noexpand\tikz@do@hvvh + {\expandafter\noexpand\pgf@tempa}% + {\expandafter\noexpand\pgf@tempb}% + {\expandafter\noexpand\pgf@temp}% + {\noexpand\tikz@timer@hvhline}{\tikz@shapeborder@name}}% + \endgroup + \pgf@marshal}% + +%% |-| operator +\def\tikzext@tikz@@vhv@lineto#1{% + \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \pgf@xc=\tikz@lastx + \pgf@yb=\tikz@lasty + \pgf@yc=\tikz@lasty + \tikz@make@last@position{#1}% + \tikz@flush@moveto@toward{\pgfqpoint{\pgf@xc}{\tikz@lasty}}\pgf@xc\pgf@yc + \begingroup + \pgfqkeys{/tikz/ortho}{/tikz/style/.expand once=\tikz@hvvh@currentoption}% + \iftikz@shapeborder + \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\tikz@lastx}{\pgf@yb}}}% + \iftikzext@tikz@hvvh@fromcenter + \pgf@yc\pgf@yb + \fi + \ifx\tikzext@tikz@hvvh@ratio\pgfutil@empty + \ifdim\tikzext@tikz@hvvh@distance<0pt\relax + \iftikzext@tikz@hvvh@fromcenter + \pgf@yc\tikz@lasty + \else + \pgf@yc\pgf@y + \fi + \fi + \ifdim\pgf@yb>\tikz@lasty + \tikzext@tikz@hvvh@distance-\tikzext@tikz@hvvh@distance + \fi + \else + \iftikzext@tikz@hvvh@fromcenter + \tikzext@tikz@hvvh@distance\tikz@lasty + \else + \tikzext@tikz@hvvh@distance\pgf@y + \fi + \advance\tikzext@tikz@hvvh@distance-\pgf@yc + \tikzext@tikz@hvvh@distance\tikzext@tikz@hvvh@ratio\tikzext@tikz@hvvh@distance + \fi + \advance\pgf@yc\tikzext@tikz@hvvh@distance + \edef\pgf@tempa{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + \edef\pgf@tempb{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\pgf@yc}}% + \edef\pgf@temp{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \else + \let\tikz@shapeborder@name\pgfutil@empty + \iftikzext@tikz@hvvh@fromcenter + \pgf@yc\pgf@yb + \fi + \ifx\tikzext@tikz@hvvh@ratio\pgfutil@empty + \ifdim\tikzext@tikz@hvvh@distance<0pt\relax + \pgf@yc\tikz@lasty + \fi + \ifdim\pgf@yb>\tikz@lasty + \tikzext@tikz@hvvh@distance-\tikzext@tikz@hvvh@distance + \fi + \else + \tikzext@tikz@hvvh@distance\tikz@lasty + \advance\tikzext@tikz@hvvh@distance-\pgf@yc + \tikzext@tikz@hvvh@distance\tikzext@tikz@hvvh@ratio\tikzext@tikz@hvvh@distance + \fi + \advance\pgf@yc\tikzext@tikz@hvvh@distance + \edef\pgf@tempa{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + \edef\pgf@tempb{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\pgf@yc}}% + \edef\pgf@temp{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \fi% + \xdef\pgf@marshal{% + \noexpand\tikz@do@hvvh + {\expandafter\noexpand\pgf@tempa}% + {\expandafter\noexpand\pgf@tempb}% + {\expandafter\noexpand\pgf@temp}% + {\noexpand\tikz@timer@vhvline}{\tikz@shapeborder@name}}% + \endgroup + \pgf@marshal}% + +%% r-ud operator +\def\tikzext@tikz@@ud@lineto#1{% + \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \pgf@xc\tikz@lastx + \pgf@yb\tikz@lasty + \advance\tikz@lasty1pt% + \let\pgf@temp\tikz@moveto@waiting + \tikz@flush@moveto@toward{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}\pgf@xc\pgf@yc + \tikz@make@last@position{#1}% + \begingroup + \pgfqkeys{/tikz/ortho}{/tikz/style/.expand once=\tikz@hvvh@currentoption}% + \pgfmathsetlength\tikzext@tikz@udlr@distance{\pgfkeysvalueof{/tikz/ortho/ud distance}}% + \iftikz@shapeborder + \advance\pgf@y1pt% + \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\pgf@x}{\pgf@y}}}% + \iftikzext@tikz@hvvh@fromcenter + \pgf@yc\pgf@yb + \else\ifx\pgf@temp\relax + \pgf@yc\pgf@yb + \fi + \fi + \ifdim\pgf@yc<\pgf@y + \iftikzext@tikz@hvvh@fromcenter + \pgf@yc=\tikz@lasty + \else + \pgf@yc=\pgf@y + \fi + \fi + \advance\pgf@yc\tikzext@tikz@udlr@distance + \edef\pgf@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \else + \let\tikz@shapeborder@name\pgfutil@empty + \ifx\pgf@temp\relax\else + \iftikzext@tikz@hvvh@fromcenter\else + \pgf@yb\pgf@yc + \fi + \fi + \ifdim\pgf@yb<\tikz@lasty\pgf@yb\tikz@lasty\fi + \advance\pgf@yb\tikzext@tikz@udlr@distance + \pgf@yc\pgf@yb + \edef\pgf@temp{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \fi + \xdef\pgf@marshal{% + \noexpand\tikz@do@hvvh + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + {\noexpand\pgfqpoint{\the\tikz@lastx}{\the\pgf@yc}}% + {\expandafter\noexpand\pgf@temp}% + {\noexpand\tikz@timer@vhvline}{\tikz@shapeborder@name}}% + \endgroup + \pgf@marshal}% + +%% r-du operator +\def\tikzext@tikz@@du@lineto#1{% + \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \pgf@xc\tikz@lastx + \pgf@yb\tikz@lasty + \advance\tikz@lasty-1pt% + \let\pgf@temp\tikz@moveto@waiting + \tikz@flush@moveto@toward{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}\pgf@xc\pgf@yc + \tikz@make@last@position{#1}% + \begingroup + \pgfqkeys{/tikz/ortho}{/tikz/style/.expand once=\tikz@hvvh@currentoption}% + \pgfmathsetlength\tikzext@tikz@udlr@distance{\pgfkeysvalueof{/tikz/ortho/du distance}}% + \iftikz@shapeborder + \advance\pgf@y-1pt% + \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\pgf@x}{\pgf@y}}}% + \iftikzext@tikz@hvvh@fromcenter + \pgf@yc\pgf@yb + \else\ifx\pgf@temp\relax + \pgf@yc\pgf@yb + \fi + \fi + \ifdim\pgf@yc>\pgf@y + \iftikzext@tikz@hvvh@fromcenter + \pgf@yc=\tikz@lasty + \else + \pgf@yc=\pgf@y + \fi + \fi + \advance\pgf@yc-\tikzext@tikz@udlr@distance + \edef\pgf@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \else + \let\tikz@shapeborder@name\pgfutil@empty + \ifx\pgf@temp\relax\else + \iftikzext@tikz@hvvh@fromcenter\else + \pgf@yb\pgf@yc + \fi + \fi + \ifdim\pgf@yb>\tikz@lasty\pgf@yb\tikz@lasty\fi + \advance\pgf@yb-\tikzext@tikz@udlr@distance + \pgf@yc\pgf@yb + \edef\pgf@temp{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \fi + \xdef\pgf@marshal{% + \noexpand\tikz@do@hvvh + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + {\noexpand\pgfqpoint{\the\tikz@lastx}{\the\pgf@yc}}% + {\expandafter\noexpand\pgf@temp}% + {\noexpand\tikz@timer@vhvline}{\tikz@shapeborder@name}}% + \endgroup + \pgf@marshal}% + +%% r-lr operator +\def\tikzext@tikz@@lr@lineto#1{% + \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \pgf@xb\tikz@lastx + \pgf@yc\tikz@lasty + \advance\tikz@lastx-1pt% + \let\pgf@temp\tikz@moveto@waiting + \tikz@flush@moveto@toward{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}\pgf@xc\pgf@yc + \tikz@make@last@position{#1}% + \begingroup + \pgfqkeys{/tikz/ortho}{/tikz/style/.expand once=\tikz@hvvh@currentoption}% + \pgfmathsetlength\tikzext@tikz@udlr@distance{\pgfkeysvalueof{/tikz/ortho/lr distance}}% + \iftikz@shapeborder + \advance\pgf@x-1pt% + \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\pgf@x}{\pgf@y}}}% + \iftikzext@tikz@hvvh@fromcenter + \pgf@xc\pgf@xb + \else\ifx\pgf@temp\relax + \pgf@xc\pgf@xb + \fi + \fi + \ifdim\pgf@xc>\pgf@x + \iftikzext@tikz@hvvh@fromcenter + \pgf@xc=\tikz@lastx + \else + \pgf@xc=\pgf@x + \fi + \fi + \advance\pgf@xc-\tikzext@tikz@udlr@distance + \edef\pgf@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \else + \let\tikz@shapeborder@name\pgfutil@empty + \ifx\pgf@temp\relax\else + \iftikzext@tikz@hvvh@fromcenter\else + \pgf@xb\pgf@xc + \fi + \fi + \ifdim\pgf@xb>\tikz@lastx\pgf@xb\tikz@lastx\fi + \advance\pgf@xb-\tikzext@tikz@udlr@distance + \pgf@xc\pgf@xb + \edef\pgf@temp{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \fi + \xdef\pgf@marshal{% + \noexpand\tikz@do@hvvh + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\tikz@lasty}}% + {\expandafter\noexpand\pgf@temp}% + {\noexpand\tikz@timer@hvhline}{\tikz@shapeborder@name}}% + \endgroup + \pgf@marshal}% + +%% r-rl operator +\def\tikzext@tikz@@rl@lineto#1{% + \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \pgf@xb\tikz@lastx + \pgf@yc\tikz@lasty + \advance\tikz@lastx1pt% + \let\pgf@temp\tikz@moveto@waiting + \tikz@flush@moveto@toward{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}\pgf@xc\pgf@yc + \tikz@make@last@position{#1}% + \begingroup + \pgfqkeys{/tikz/udlr}{/tikz/ortho/.expand once=\tikz@hvvh@currentoption}% + \pgfmathsetlength\tikzext@tikz@udlr@distance{\pgfkeysvalueof{/tikz/ortho/rl distance}}% + \iftikz@shapeborder% + \advance\pgf@x1pt% + \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\pgf@x}{\pgf@y}}}% + \iftikzext@tikz@hvvh@fromcenter + \pgf@xc\pgf@xb + \else\ifx\pgf@temp\relax + \pgf@xc\pgf@xb + \fi + \fi + \ifdim\pgf@xc<\pgf@x + \iftikzext@tikz@hvvh@fromcenter + \pgf@xc=\tikz@lastx + \else + \pgf@xc=\pgf@x + \fi + \fi + \advance\pgf@xc\tikzext@tikz@udlr@distance + \edef\pgf@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \else + \let\tikz@shapeborder@name\pgfutil@empty% + \ifx\pgf@temp\relax\else + \iftikzext@tikz@hvvh@fromcenter\else + \pgf@xb\pgf@xc + \fi + \fi + \ifdim\pgf@xb<\tikz@lastx\pgf@xb\tikz@lastx\fi + \advance\pgf@xb\tikzext@tikz@udlr@distance + \pgf@xc\pgf@xb + \edef\pgf@temp{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \fi + \xdef\pgf@marshal{% + \noexpand\tikz@do@hvvh + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\tikz@lasty}}% + {\expandafter\noexpand\pgf@temp}% + {\noexpand\tikz@timer@hvhline}{\tikz@shapeborder@name}}% + \endgroup + \pgf@marshal}% + +%% a few nice to haves, use with to or edge operator +\tikzset{ + node as new start/.is if=tikzext@ortho@preflush, + node as new start, + ortho/install shortcuts/.style={ + *|/.style={only vertical second={#1}}, *|/.default=, + |*/.style={only vertical first={#1}}, |*/.default=, + *-/.style={only horizontal second={#1}}, *-/.default=, + -*/.style={only horizontal first={#1}}, -*/.default=, + |-/.style={to path={|-(\tikztotarget)\tikztonodes}}, + -|/.style={to path={-|(\tikztotarget)\tikztonodes}}, + -|-/.style=/tikz/horizontal vertical horizontal, + |-|/.style=/tikz/vertical horizontal vertical, + }, + horizontal vertical/.style={to path={-| (\tikztotarget) \tikztonodes}}, + vertical horizontal/.style={to path={|- (\tikztotarget) \tikztonodes}}, + horizontal vertical horizontal/.style={to path={-|- (\tikztotarget) \tikztonodes}}, + vertical horizontal vertical/.style={to path={|-| (\tikztotarget) \tikztonodes}}, + only vertical second/.style={to path={ + \pgfextra + \let\tikzext@ortho@anchor\pgfutil@empty + \let\tikzext@origtotarget\pgfutil@empty + \tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax + \iftikz@shapeborder + \tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax + \ifdim\pgf@y>\tikz@lasty\relax + \edef\tikztostart{\tikztostart.north}% + \iftikz@shapeborder\def\tikzext@ortho@anchor{.south}\fi + \else + \edef\tikztostart{\tikztostart.south}% + \iftikz@shapeborder\def\tikzext@ortho@anchor{.north}\fi + \fi + \fi + \def\tikz@tempa{#1}% + \ifx\tikz@tempa\pgfutil@empty\else + \let\tikzext@origtotarget\tikztotarget + \edef\tikztotarget{[xshift={#1}]\tikztotarget\tikzext@ortho@anchor}% + \fi + \endpgfextra + [insert path/.expanded={ + (perpendicular cs: horizontal line through={(\tikztostart)}, + vertical line through={(\tikztotarget)}) -- (\tikztotarget)}] \tikztonodes + \pgfextra + \ifx\tikzext@origtotarget\pgfutil@empty\else + \iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi\endpgfextra}}, + only vertical second/.default=, + only horizontal second/.style={to path={ + \pgfextra + \let\tikzext@ortho@anchor\pgfutil@empty + \let\tikzext@origtotarget\pgfutil@empty + \tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax + \iftikz@shapeborder + \tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax + \ifdim\pgf@x>\tikz@lastx\relax + \edef\tikztostart{\tikztostart.east}% + \iftikz@shapeborder\def\tikzext@ortho@anchor{.west}\fi + \else + \edef\tikztostart{\tikztostart.west}% + \iftikz@shapeborder\def\tikzext@ortho@anchor{.east}\fi + \fi + \fi + \def\tikz@tempa{#1}% + \ifx\tikz@tempa\pgfutil@empty\else + \let\tikzext@origtotarget\tikztotarget + \edef\tikztotarget{[yshift={#1}]\tikztotarget\tikzext@ortho@anchor}% + \fi + \endpgfextra + [insert path/.expanded={ + (perpendicular cs: vertical line through={(\tikztostart)}, + horizontal line through={(\tikztotarget)}) -- (\tikztotarget)}] \tikztonodes + \pgfextra + \ifx\tikzext@origtotarget\pgfutil@empty\else + \iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi\endpgfextra}}, + only horizontal second/.default=, + only vertical first/.style={to path={ + \pgfextra + \let\tikzext@ortho@anchor\pgfutil@empty + \let\tikzext@origtotarget\pgfutil@empty + \tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax + \pgf@ya=\pgf@y + \iftikz@shapeborder + \let\tikzext@origtotarget\tikztotarget + \tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax + \ifdim\pgf@ya>\tikz@lasty\relax + \edef\tikztotarget{\tikztotarget.south}% + \iftikz@shapeborder\def\tikzext@ortho@anchor{.north}\fi + \else + \edef\tikztotarget{\tikztotarget.north}% + \iftikz@shapeborder\def\tikzext@ortho@anchor{.south}\fi + \fi + \fi + \def\tikz@tempa{#1}% + \ifx\tikz@tempa\pgfutil@empty\else + \edef\tikztostart{[xshift={#1}]\tikztostart\tikzext@ortho@anchor}% + \fi + \endpgfextra + [insert path/.expanded={(\tikztostart)}] + -- (perpendicular cs: vertical line through/.expanded={(\tikztostart)}, + horizontal line through={(\tikztotarget)}) + \tikztonodes + \pgfextra + \ifx\tikzext@origtotarget\pgfutil@empty\else + \iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi\endpgfextra}}, + only vertical first/.default=, + only horizontal first/.style={to path={ + \pgfextra + \let\tikzext@ortho@anchor\pgfutil@empty + \let\tikzext@origtotarget\pgfutil@empty + \tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax + \pgf@xa=\pgf@x + \iftikz@shapeborder + \let\tikzext@origtotarget\tikztotarget + \tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax + \ifdim\pgf@xa>\tikz@lastx\relax + \edef\tikztotarget{\tikztotarget.west}% + \iftikz@shapeborder\def\tikzext@ortho@anchor{.east}\fi + \else + \edef\tikztotarget{\tikztotarget.east}% + \iftikz@shapeborder\def\tikzext@ortho@anchor{.west}\fi + \fi + \fi + \def\tikz@tempa{#1}% + \ifx\tikz@tempa\pgfutil@empty\else + \edef\tikztostart{[yshift={#1}]\tikztostart\tikzext@ortho@anchor}% + \fi + \endpgfextra + [insert path/.expanded={(\tikztostart)}] + -- (perpendicular cs: horizontal line through/.expanded={(\tikztostart)}, + vertical line through={(\tikztotarget)}) + \tikztonodes \pgfextra + \ifx\tikzext@origtotarget\pgfutil@empty\else + \iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi\endpgfextra}}, + only horizontal first/.default=, + only vertical first to center/.style={to path={ + \pgfextra + \let\tikzext@origtotarget\tikztotarget + \endpgfextra + (\tikztostart) -- (perpendicular cs: vertical line through={(\tikztostart)}, + horizontal line through={(\tikztotarget)}) + \tikztonodes \ifx\tikzext@origtotarget\pgfutil@empty\else\iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi}}, + only horizontal first to center/.style={to path={ + \pgfextra + \let\tikzext@origtotarget\tikztotarget + \endpgfextra + (\tikztostart) -- (perpendicular cs: horizontal line through={(\tikztostart)}, + vertical line through={(\tikztotarget)}) + \tikztonodes \ifx\tikzext@origtotarget\pgfutil@empty\else\iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi}}% +} +\endinput
\ No newline at end of file diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.paths.timer.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.paths.timer.code.tex new file mode 100644 index 0000000000..3a4d30e68f --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.paths.timer.code.tex @@ -0,0 +1,188 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +\def\tikz@rectB#1{% originally from tikz.code.tex + \tikz@make@last@position{#1}% + \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \let\tikz@timer\tikz@timer@rectangle% %% Timer: new timer + \tikz@@movetosave{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \tikz@path@lineto{\pgfqpoint{\pgf@xa}{\tikz@lasty}}% + \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}% + \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\pgf@ya}}% + \iftikz@snaked + \tikz@path@lineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \fi + \pgfpathclose + \tikz@@movetosave{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}% + \def\pgfstrokehook{}% + \let\tikz@tangent\relax + \tikz@scan@next@command +}% + +\def\tikz@@sine#1{% originally from tikz.code.tex + \let\tikz@tangent\tikz@tangent@lookup + \tikz@flush@moveto + \edef\tikz@timer@start{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save start position + \pgf@process{#1}% + \edef\tikz@timer@end{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% %% Timer: saver target position + \pgf@xc=\pgf@x + \pgf@yc=\pgf@y + \advance\pgf@xc by-\tikz@lastx + \advance\pgf@yc by-\tikz@lasty + \advance\tikz@lastx by\pgf@xc + \advance\tikz@lasty by\pgf@yc + \tikz@lastxsaved=\tikz@lastx + \tikz@lastysaved=\tikz@lasty + \tikz@updatecurrenttrue + \let\tikz@timer=\tikz@timer@sine% %% Timer: new timer + \pgfpathsine{\pgfqpoint{\pgf@xc}{\pgf@yc}}% + \tikz@scan@next@command +} + +\def\tikz@@cosine#1{% originally from tikz.code.tex + \let\tikz@tangent\tikz@tangent@lookup + \tikz@flush@moveto + \edef\tikz@timer@start{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save start position + \pgf@process{#1}% + \edef\tikz@timer@end{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% %% Timer: save target position + \pgf@xc=\pgf@x + \pgf@yc=\pgf@y + \advance\pgf@xc by-\tikz@lastx + \advance\pgf@yc by-\tikz@lasty + \advance\tikz@lastx by\pgf@xc + \advance\tikz@lasty by\pgf@yc + \tikz@lastxsaved=\tikz@lastx + \tikz@lastysaved=\tikz@lasty + \tikz@updatecurrenttrue + \let\tikz@timer=\tikz@timer@cosine% %% Timer: new timer + \pgfpathcosine{\pgfqpoint{\pgf@xc}{\pgf@yc}}% + \tikz@scan@next@command +} + +\def\tikz@timer@rectangle{% + \pgfutil@tempdima\tikz@time pt + \ifdim\pgfutil@tempdima<.5pt\else % if we're at the return pos-ition we switch start and end + \advance\pgfutil@tempdima-.5pt + \let\pgf@tempa\tikz@timer@start + \let\tikz@timer@start\tikz@timer@end + \let\tikz@timer@end\pgf@tempa + \fi + \multiply\pgfutil@tempdima2 + \edef\tikz@time{\strip@pt\pgfutil@tempdima}% + \tikz@timer@hvline}% + +\def\tikz@parabola@semifinal#1{% + \tikz@flush@moveto + % Save original start: + \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save start position + \pgf@xb=\tikz@lastx + \pgf@yb=\tikz@lasty + \tikz@make@last@position{#1}% + \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save target position + \pgf@xc=\tikz@lastx + \pgf@yc=\tikz@lasty + \begingroup% now calculate bend: + \let\tikz@after@path\pgfutil@empty + \expandafter\tikzset\expandafter{\tikz@parabola@option}% + \tikz@lastxsaved=\tikz@parabola@bend@factor\tikz@lastx + \tikz@lastysaved=\tikz@parabola@bend@factor\tikz@lasty + \advance\tikz@lastxsaved by\pgf@xb + \advance\tikz@lastysaved by\pgf@yb + \advance\tikz@lastxsaved by-\tikz@parabola@bend@factor\pgf@xb + \advance\tikz@lastysaved by-\tikz@parabola@bend@factor\pgf@yb + \expandafter\tikz@make@last@position\expandafter{\tikz@parabola@bend}% + \edef\tikz@timer@middle{{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save bend postion + % Calculate delta from bend + \advance\pgf@xc by-\tikz@lastx + \advance\pgf@yc by-\tikz@lasty + % Ok, now calculate delta to bend + \advance\tikz@lastx by-\pgf@xb + \advance\tikz@lasty by-\pgf@yb + \edef\tikz@marshall{% + \noexpand\let\noexpand\tikz@timer\noexpand\tikz@timer@parabola + \noexpand\edef\noexpand\tikz@timer@middle{\noexpand\pgfqpoint\tikz@timer@middle}% + \noexpand\pgfpathparabola{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + }% + \expandafter\endgroup% + \tikz@marshall + \expandafter\tikz@scan@next@command\tikz@after@path% +}% + +\def\tikz@timer@parabola{% following calculations, see \def of \pgfpathparabola in pgfcorepathconstruct.code.tex (l. 1261) + \ifdim\tikz@time pt<.5pt\relax % first part + \pgf@process{\tikz@timer@middle}% + \pgf@xc\pgf@x\pgf@yc\pgf@y + \pgf@xb\pgf@x\pgf@yb\pgf@y + \pgf@process{\tikz@timer@start}% + \advance\pgf@xc-\pgf@x\pgf@xc.1125\pgf@xc + \advance\pgf@xc\pgf@x % = start_x + .1125 (middle_x - start_x) + \advance\pgf@yc-\pgf@y\pgf@yc.225\pgf@yc + \advance\pgf@yc\pgf@y % = start_y + .225 (middle_y - start_y) + \advance\pgf@xb\pgf@x\pgf@xb.5\pgf@xb % = .5 (middle_x + start_x) = start_x + .5 (middle_x - start_x) + \pgf@xa=\tikz@time pt% + \pgf@xa=2\pgf@xa % = 2 * \tikz@time + \edef\tikz@marshall{\noexpand\pgftransformcurveattime{\strip@pt\pgf@xa}{\noexpand\tikz@timer@start}% + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% + {\noexpand\tikz@timer@middle}}% + \else % second part + \pgf@process{\tikz@timer@end}% + \pgf@xc\pgf@x + \pgf@xb\pgf@x + \pgf@yb\pgf@y + \pgf@process{\tikz@timer@middle}% + \advance\pgf@xc\pgf@x\pgf@xc.5\pgf@xc % = .5 (end_x + middle_x) = middle_x + .5 (end_x - middle_x) + \advance\pgf@xb-\pgf@x\pgf@xb.8875\pgf@xb + \advance\pgf@xb\pgf@x % = middle_x + .8875 (end_x - middle_x) + \advance\pgf@yb-\pgf@y\pgf@yb.775\pgf@yb + \advance\pgf@yb\pgf@y % = middle_y + .775 (end_y - middle_y) + \pgf@xa=\tikz@time pt% + \advance\pgf@xa-.5pt% + \pgf@xa=2\pgf@xa % = 2 (\tikz@zime - .5) + \edef\tikz@marshall{\noexpand\pgftransformcurveattime{\strip@pt\pgf@xa}{\noexpand\tikz@timer@middle}% + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@y}}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% + {\noexpand\tikz@timer@end}}% + \fi + \tikz@marshall +} + +\def\tikz@timer@sine{% following calculations, see \def of \pgfpathsine in pgfcorepathconstruct.code.tex (l. 1315) + \pgf@process{\tikz@timer@end}% + \pgf@xc\pgf@x\pgf@yc\pgf@y + \pgf@xb\pgf@x\pgf@yb\pgf@y + \pgf@process{\tikz@timer@start}% + \advance\pgf@xc-\pgf@x\pgf@xc.3260\pgf@xc + \advance\pgf@xc\pgf@x % = start_x + .3260 (end_x - start_x) + \advance\pgf@yc-\pgf@y\pgf@yc.5120\pgf@yc + \advance\pgf@yc\pgf@y % = start_y + .5120 (end_y - start_y) + \advance\pgf@xb-\pgf@x\pgf@xb.6380\pgf@xb % = start_x + .6380 (end_x - start_x) + \advance\pgf@xb\pgf@x + \edef\tikz@marshall{\noexpand\pgftransformcurveattime{\tikz@time}{\noexpand\tikz@timer@start}% + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% + {\noexpand\tikz@timer@end}}% + \tikz@marshall +} +\def\tikz@timer@cosine{% following calculations, see \def of \pgfpathcosine in pgfcorepathconstruct.code.tex (l. 1345) + \pgf@process{\tikz@timer@end}% + \pgf@xc\pgf@x\pgf@yc\pgf@y + \pgf@xb\pgf@x\pgf@yb\pgf@y + \pgf@process{\tikz@timer@start}% + \advance\pgf@xb-\pgf@x\pgf@xb.6740\pgf@xb + \advance\pgf@xb\pgf@x % = start_x + .6740 (end_x - start_x) + \advance\pgf@yb-\pgf@y\pgf@yb.4880\pgf@yb + \advance\pgf@yb\pgf@y % = start_y + .4880 (end_y - start_y) + \advance\pgf@xc-\pgf@x\pgf@xc.3620\pgf@xc % = start_x + .3620 (end_x - start_x) + \advance\pgf@xc\pgf@x + \edef\tikz@marshall{\noexpand\pgftransformcurveattime{\tikz@time}{\noexpand\tikz@timer@start}% + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@y}}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% + {\noexpand\tikz@timer@end}}% + \tikz@marshall +} +\endinput
\ No newline at end of file diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.patterns.images.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.patterns.images.code.tex new file mode 100644 index 0000000000..aa732ab835 --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.patterns.images.code.tex @@ -0,0 +1,60 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +% This is the TikZ library patterns.images +% Load with \usetikzlibrary{patterns.images} +% +% Macro: +% - \pgfSetupImageAsPattern[<opt arguments for \pgfdeclareimage>]{<name>}{<path/file>} +% +% Keys are: +% - use image as pattern=<name> +% - image as pattern=<opt arguments for \pgftext> + +\def\pgfsetupimageaspattern{\pgfutil@ifnextchar[\tikzext@pgfsetupimageaspattern{\tikzext@pgfsetupimageaspattern[]}} +\def\tikzext@pgfsetupimageaspattern[#1]#2#3{% #1 = options + % #2 = image name + % #3 = file name + \pgfdeclareimage[#1]{tikzext@pgf@iap@#2}{#3}% + \sbox\pgfutil@tempboxa{\pgfuseimage{tikzext@pgf@iap@#2}}% + \expandafter\edef\csname tikzext@pgf@iap@#2@\endcsname{{\the\wd\pgfutil@tempboxa}{\the\ht\pgfutil@tempboxa}}% +} +\tikzset{ + image as pattern/name/.initial=, + image as pattern/option/.style=, + image as pattern/options/.style={/tikz/image as pattern/option/.append style={#1}}, + image as pattern/.default=, + image as pattern/.code={ + \pgfqkeys{/tikz/image as pattern}{#1}% + \pgfkeysgetvalue{/tikz/image as pattern/name}\tikz@temp + \pgfutil@ifxempty\tikz@temp{% + \tikzerror{You need to specify a name for the ``image-pattern'' to be used.}% + }{% + \edef\tikz@tempa{\expandafter\expandafter\expandafter\pgfutil@firstoftwo\csname tikzext@pgf@iap@\tikz@temp @\endcsname}% + \edef\tikz@tempb{\expandafter\expandafter\expandafter\pgfutil@secondoftwo\csname tikzext@pgf@iap@\tikz@temp @\endcsname}% + \pgfkeysalso{/tikz/path picture={% + \pgf@process{\pgfpointanchor{path picture bounding box}{north east}}% + \pgf@xa\pgf@x\pgf@ya\pgf@y + \pgf@process{\pgfpointanchor{path picture bounding box}{south west}}% + \pgf@xb\pgf@x\pgf@yb\pgf@y\pgf@yc\pgf@yb + \pgfutil@loop + {% + \pgfutil@loop + \expandafter\pgftext\expandafter[/tikz/image as pattern/option,at=\pgfqpoint{\pgf@xb}{\pgf@yb}]{\pgfuseimage{tikzext@pgf@iap@\tikz@temp}}% + \ifdim\pgf@yb<\pgf@ya + \advance\pgf@yb\tikz@tempb + \pgfutil@repeat + }% + \ifdim\pgf@xb<\pgf@xa + \advance\pgf@xb\tikz@tempa + \pgf@yb\pgf@yc + \pgfutil@repeat + }}% + } + } +} +\endinput diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.positioning-plus.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.positioning-plus.code.tex new file mode 100644 index 0000000000..98de181c27 --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.positioning-plus.code.tex @@ -0,0 +1,262 @@ +% This is the TikZ library positioning-plus +% Load with \usetikzlibrary{positioning-plus} +% +% This small library extends TikZ options like 'above', 'left' or 'below right' +% so that they can be used with an optional prefixed factor seperated by ':' (colon) +% +% The option 'left=.5:of somenode' will place +% a new node .5cm (default 'node distance' is '1cm and 1cm') left to (somenode). +% The option 'above right=.2 and .7:of someothernode' will place +% a new node .2cm above and .7cm right of (someothernode). +% +% Additional the options 'xshift*' and 'yshift*' add an additional shift +% as a factor of 'node distance' +% Inspired by http://tex.stackexchange.com/a/117610/16595 + +\usetikzlibrary{positioning} +\usetikzlibrary{fit} + +\pgfdeclaregenericanchor{corner south east}{% + \pgf@sh@reanchor{#1}{south}% + \pgf@ya\pgf@y + \pgf@process{\pgf@sh@reanchor{#1}{east}}% + \pgf@y\pgf@ya +} +\pgfdeclaregenericanchor{corner north east}{% + \pgf@sh@reanchor{#1}{north}% + \pgf@ya\pgf@y + \pgf@process{\pgf@sh@reanchor{#1}{east}}% + \pgf@y\pgf@ya +} +\pgfdeclaregenericanchor{corner south west}{% + \pgf@sh@reanchor{#1}{south}% + \pgf@ya\pgf@y + \pgf@process{\pgf@sh@reanchor{#1}{west}}% + \pgf@y\pgf@ya +} +\pgfdeclaregenericanchor{corner north west}{% + \pgf@sh@reanchor{#1}{north}% + \pgf@ya\pgf@y + \pgf@process{\pgf@sh@reanchor{#1}{west}}% + \pgf@y\pgf@ya +} + +\tikzset{corner above left/.code=\tikz@lib@place@handle@{#1}{corner south east}{-1}{1}{corner north west}{0.707106781}} +\tikzset{corner above right/.code=\tikz@lib@place@handle@{#1}{corner south west}{1}{1}{corner north east}{0.707106781}} +\tikzset{corner below left/.code=\tikz@lib@place@handle@{#1}{corner north east}{-1}{-1}{corner south west}{0.707106781}} +\tikzset{corner below right/.code=\tikz@lib@place@handle@{#1}{corner north west}{1}{-1}{corner south east}{0.707106781}} + +\tikzset{corner north left/.code =\tikz@lib@place@handle@{#1}{corner north east}{-1}{0}{corner north west}{1}} +\tikzset{corner north right/.code=\tikz@lib@place@handle@{#1}{corner north west}{1}{0}{corner north east}{1}} +\tikzset{corner south left/.code =\tikz@lib@place@handle@{#1}{corner south east}{-1}{0}{corner south west}{1}} +\tikzset{corner south right/.code=\tikz@lib@place@handle@{#1}{corner south west}{1}{0}{corner south east}{1}} + +\tikzset{corner west above/.code =\tikz@lib@place@handle@{#1}{corner south west}{0}{1}{corner north west}{1}} +\tikzset{corner west below/.code=\tikz@lib@place@handle@{#1}{corner north west}{0}{-1}{corner south west}{1}} +\tikzset{corner east above/.code =\tikz@lib@place@handle@{#1}{corner south east}{0}{1}{corner north east}{1}} +\tikzset{corner east below/.code=\tikz@lib@place@handle@{#1}{corner north east}{0}{-1}{corner south east}{1}} + +\tikzset{north left/.code =\tikz@lib@place@handle@{#1}{north east}{-1}{0}{north west}{1}} +\tikzset{north right/.code=\tikz@lib@place@handle@{#1}{north west}{1}{0}{north east}{1}} +\tikzset{south left/.code =\tikz@lib@place@handle@{#1}{south east}{-1}{0}{south west}{1}} +\tikzset{south right/.code=\tikz@lib@place@handle@{#1}{south west}{1}{0}{south east}{1}} + +\tikzset{west above/.code =\tikz@lib@place@handle@{#1}{south west}{0}{1}{north west}{1}} +\tikzset{west below/.code=\tikz@lib@place@handle@{#1}{north west}{0}{-1}{south west}{1}} +\tikzset{east above/.code =\tikz@lib@place@handle@{#1}{south east}{0}{1}{north east}{1}} +\tikzset{east below/.code=\tikz@lib@place@handle@{#1}{north east}{0}{-1}{south east}{1}} + +\newif\iftikzext@tikz@lib@place@postransform +\tikzset{node distance transformation/.is if=qrr@tikz@lib@place@postransform} +\def\tikz@lib@place@handle@@#1#2#3#4{% + \pgfutil@in@{of }{#1}% + \ifpgfutil@in@ + \tikz@lib@place@of#1\tikz@stop{#4}% + \else + \edef\tikz@lib@place@nums{#1}% + \fi + \ifx\tikz@lib@place@nums\pgfutil@empty + % Ok, nothing to do, we have set the anchor and we are happy... + \else + \expandafter\tikz@lib@place@parse@nums\expandafter{\tikz@lib@place@nums}% + \pgf@x=#2\pgf@x + \pgf@y=#3\pgf@y + \iftikzext@tikz@lib@place@postransform + \pgf@pos@transform{\pgf@x}{\pgf@y}% change from original + \fi + \edef\tikz@lib@pos@call{\noexpand\pgftransformshift{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}% + \fi +} + +\def\tikz@lib@place@handle@#1#2#3#4#5#6{% + \pgfutil@in@{:}{#1}% + \ifpgfutil@in@ + \tikzext@lib@place@handle@#1\tikz@stop + \ifx\pgf@temp\pgfutil@empty + \let\pgf@temp\tikz@node@distance + \fi + \pgfmathsetmacro\pgf@tempa{(\pgf@tempa)*#4}% + \pgfmathsetmacro\pgf@tempb{(\pgf@tempb)*#3}% + \edef\pgf@marshal{\noexpand\tikz@lib@place@handle@{\pgf@temp}{#2}{\pgf@tempb}{\pgf@tempa}{#5}{#6}}% + \pgf@marshal + \else + \def\tikz@anchor{#2}% + \let\tikz@do@auto@anchor=\relax + \edef\tikz@temp{#1}% + \def\tikz@lib@place@single@factor{#6}% + \expandafter\tikz@lib@place@handle@@\expandafter{\tikz@temp}{#3}{#4}{#5}% + \fi +} +\def\tikzext@lib@place@handle@#1:#2\tikz@stop{% + \pgfutil@in@{and}{#1}% + \ifpgfutil@in@ + \tikzext@lib@place@handle@@#1\tikz@stop + \else + \tikzext@lib@place@handle@@#1and#1\tikz@stop + \fi + \def\pgf@temp{#2}% +} +\def\tikzext@lib@place@handle@@#1and#2\tikz@stop{% + \def\pgf@tempa{#1}% + \def\pgf@tempb{#2}% +} +\def\tikzext@xyshift@starred#1#2#3{% + \edef\tikz@marshal{\noexpand\pgfutil@in@{and}{\tikz@node@distance}}% + \tikz@marshal + \ifpgfutil@in@ + \expandafter\tikzext@lib@place@handle@@\tikz@node@distance\tikz@stop + \else + \let#3\tikz@node@distance + \fi + \pgfmathparse{(#1)*#3}% + \ifpgfmathunitsdeclared + \if#2x% + \pgftransformshift{\pgfqpoint{\pgfmathresult pt}{0pt}}% + \else + \pgftransformshift{\pgfqpoint{0pt}{\pgfmathresult pt}}% + \fi + \else + \ifx#2x% + \pgf@process{\pgfqpointxy{\pgfmathresult}{0}}% + \else + \pgf@process{\pgfqpointxy{0}{\pgfmathresult}}% + \fi + \pgftransformshift{\pgfqpoint{\pgf@x}{\pgf@y}}% + \fi} +\tikzset{ + xshift*/.code=\tikzext@xyshift@starred{#1}x\pgf@tempb, + yshift*/.code=\tikzext@xyshift@starred{#1}y\pgf@tempa +} + +\def\pgfutil@firstofmany#1#2\pgf@stop{#1} +\def\pgfutil@secondofmany#1#2\pgf@stop{#2} +\def\tikz@lib@place@of@#1#2#3{% + \def\pgf@tempa{fit bounding box}% + \edef\pgf@temp{\expandafter\pgfutil@firstofmany#2\pgf@stop} + \if\pgf@temp(% + \tikz@lib@place@fit@scan{#2}{0}% + \else\if\pgf@temp|% + \expandafter\tikz@lib@place@fit@scan\expandafter{\pgfutil@secondofmany#2\pgf@stop}{1}% + \else\ifx\pgf@temp\tikz@activebar + \expandafter\tikz@lib@place@fit@scan\expandafter{\pgfutil@secondofmany#2\pgf@stop}{1}% + \else\if\pgf@temp-% + \expandafter\tikz@lib@place@fit@scan\expandafter{\pgfutil@secondofmany#2\pgf@stop}{2}% + \else\if\pgf@temp+% + \expandafter\tikz@lib@place@fit@scan\expandafter{\pgfutil@secondofmany#2\pgf@stop}{3}% + \else + \def\pgf@tempa{#2}% + \fi + \fi + \fi + \fi + \fi + \expandafter\tikz@scan@one@point\expandafter\tikz@lib@place@remember\expandafter(\pgf@tempa)% + \iftikz@shapeborder% + % Ok, this is relative to a border. + \iftikz@lib@ignore@size% + \edef\tikz@node@at{\noexpand\pgfpointanchor{\tikz@shapeborder@name}{center}}% + \def\tikz@anchor{center}% + \else% + \edef\tikz@node@at{\noexpand\pgfpointanchor{\tikz@shapeborder@name}{#3}}% + \fi% + \fi% + \edef\tikz@lib@place@nums{#1}% +} +\def\tikz@lib@place@fit@scan#1#2{% + \pgf@xb=-16000pt\relax% + \pgf@xa=16000pt\relax% + \pgf@yb=-16000pt\relax% + \pgf@ya=16000pt\relax% + \if\pgfutil@firstofmany#1\pgf@stop(% + \tikz@lib@fit@scan#1\pgf@stop% + \else + \tikz@lib@fit@scan(#1)\pgf@stop + \fi + \ifdim\pgf@xa>\pgf@xa + % shouldn't happen + \else + \expandafter\def\csname pgf@sh@ns@fit bounding box\endcsname{rectangle}% + \expandafter\edef\csname pgf@sh@np@fit bounding box\endcsname{% + \def\noexpand\southwest{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \def\noexpand\northeast{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% + }% + \expandafter\def\csname pgf@sh@nt@fit bounding box\endcsname{{1}{0}{0}{1}{0pt}{0pt}}% + \expandafter\def\csname pgf@sh@pi@fit bounding box\expandafter\endcsname\expandafter{\pgfpictureid}% + \ifcase#2\relax + \or % 1 = vertical + \pgf@y=\pgf@yb% + \advance\pgf@y by-\pgf@ya% + \edef\pgf@marshal{\noexpand\pgfset{minimum height={\the\pgf@y-2*(\noexpand\pgfkeysvalueof{/pgf/outer ysep})}}}% + \pgf@marshal + \or % 2 = horizontal + \pgf@x=\pgf@xb% + \advance\pgf@x by-\pgf@xa% + \edef\pgf@marshal{\noexpand\pgfset{minimum width={\the\pgf@x-2*(\noexpand\pgfkeysvalueof{/pgf/outer xsep})}}}% + \pgf@marshal + \or % 3 = both directions + \pgf@y=\pgf@yb% + \advance\pgf@y by-\pgf@ya% + \pgf@x=\pgf@xb% + \advance\pgf@x by-\pgf@xa% + \edef\pgf@marshal{\noexpand\pgfset{minimum height={\the\pgf@y-2*(\noexpand\pgfkeysvalueof{/pgf/outer ysep})},minimum width={\the\pgf@x-2*(\noexpand\pgfkeysvalueof{/pgf/outer xsep})}}}% + \pgf@marshal + \fi + \fi +} +\tikzset{ + fit bounding box/.code={\tikz@lib@place@fit@scan{#1}{0}}, + span vertical/.code={\tikz@lib@place@fit@scan{#1}{1}}, + span horizontal/.code={\tikz@lib@place@fit@scan{#1}{2}}, + span/.code={\tikz@lib@place@fit@scan{#1}{3}}} + +\pgfmathdeclarefunction{x_node_dist}{0}{% + \begingroup + \edef\pgfmath@temp{\noexpand\pgfutil@in@{and}{\tikz@node@distance}}% + \pgfmath@temp\ifpgfutil@in@ + \expandafter\tikzext@lib@place@handle@@\tikz@node@distance\tikz@stop + \else + \let\pgf@tempb\tikz@node@distance + \fi + \pgfmathparse{\pgf@tempb}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\pgfmathdeclarefunction{y_node_dist}{0}{% + \begingroup + \edef\pgfmath@temp{\noexpand\pgfutil@in@{and}{\tikz@node@distance}}% + \pgfmath@temp\ifpgfutil@in@ + \expandafter\tikzext@lib@place@handle@@\tikz@node@distance\tikz@stop + \else + \let\pgf@tempa\tikz@node@distance + \fi + \pgfmathparse{\pgf@tempa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +%\tikzdeclarecoordinatesystem{node distance}{% +% \tikz@cs@nd#1\tikz@stop} +%\def\tikz@cs@nd#1,#2\tikz@stop{% +% \def\tikzext@xyshift@starred@action##1{\pgftransformshift{##1}}% +% \tikzext@xyshift@starred{#1}x\pgf@tempb +% \tikzext@xyshift@starred{#2}y\pgf@tempa} +\endinput diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.topaths.arcthrough.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.topaths.arcthrough.code.tex new file mode 100644 index 0000000000..d90a2edc78 --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.topaths.arcthrough.code.tex @@ -0,0 +1,50 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% + +\pgfqkeys{/tikz/arc through}{ + .unknown/.code=\pgfkeyssetevalue{/tikz/arc through/through}{\pgfkeyscurrentname}, + through/.initial={(0,0)}, + center suffix/.initial=, + clockwise/.code=% + \def\tikz@arcthrough@clockwise{% + \pgfmathsubtract@{\pgfkeysvalueof{/tikz/end angle}}{360}% + \pgfkeyssetevalue{/tikz/end angle}{+\pgfmathresult}}, + counter clockwise/.code=\let\tikz@arcthrough@clockwise\relax, + clockwise/.value forbidden, counter clockwise/.value forbidden, counter clockwise} +\tikzset{ + arc through/.code={% + \tikzset{every arc through/.try}% + \pgfqkeys{/tikz/arc through}{#1}% + \pgfkeysgetvalue{/tikz/arc through/through}\tikz@temp + \pgfextract@process\pgf@tostart{\tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax}% + \expandafter\pgfextract@process\expandafter\pgf@tothrough\expandafter + {\expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\tikz@temp\relax}% + \pgfextract@process\pgf@totarget{\tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax}% + \pgfextract@process\pgf@topointMidA{\pgfpointlineattime{.5}{\pgf@tostart}{\pgf@tothrough}}% + \pgfextract@process\pgf@topointMidB{\pgfpointlineattime{.5}{\pgf@totarget}{\pgf@tothrough}}% + \pgfextract@process\pgf@tocenter{% + \pgfpointintersectionoflines + {\pgf@topointMidA}{\pgfmathrotatepointaround{\pgf@tothrough}{\pgf@topointMidA}{90}}% + {\pgf@topointMidB}{\pgfmathrotatepointaround{\pgf@tothrough}{\pgf@topointMidB}{90}}}% + \pgfcoordinate{arc through center\pgfkeysvalueof{/tikz/arc through/center suffix}}{\pgf@tocenter}% + \pgfpointdiff{\pgf@tocenter}{\pgf@tostart}% + \pgfmathveclen@{\pgfmath@tonumber\pgf@x}{\pgfmath@tonumber\pgf@y}% + \pgfkeyssetevalue{/tikz/x radius}{+\pgfmathresult pt}% + \pgfkeyssetevalue{/tikz/y radius}{+\pgfmathresult pt}% + \pgfmathanglebetweenpoints{\pgf@tocenter}{\pgf@totarget}% + \pgfkeyssetevalue{/tikz/end angle}{+\pgfmathresult}% + \pgfmathanglebetweenpoints{\pgf@tocenter}{\pgf@tostart}% + \ifdim\pgfmathresult pt>\pgfkeysvalueof{/tikz/end angle}pt\relax + \pgfmathsubtract@{\pgfmathresult}{360}% + \fi + \pgfkeyssetevalue{/tikz/start angle}{+\pgfmathresult}% + \tikz@arcthrough@clockwise + \pgfkeyslet{/tikz/delta angle}\pgfutil@empty + \def\tikz@to@path{arc[]\tikztonodes}% + }% +} diff --git a/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.transformations.mirror.code.tex b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.transformations.mirror.code.tex new file mode 100644 index 0000000000..026b39ab2f --- /dev/null +++ b/graphics/pgf/contrib/tikz-ext/tex/generic/tikz-ext/tikzlibraryext.transformations.mirror.code.tex @@ -0,0 +1,130 @@ +% Copyright 2022 by Qrrbrbirlbel +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +\usepgflibrary{ext.transformations.mirror} +\tikzset{ + mirror/.code={% + \pgfutil@in@{--}{#1}% + \ifpgfutil@in@ + \tikzext@trans@mirror#1\tikz@stop + \else + \tikz@addtransform{\tikz@scan@one@point\pgfqtransformmirror#1\relax}% + \fi}, + ymirror/.code={\pgfutil@ifnextchar(\tikzext@trans@ymirror@coordinate\tikzext@trans@ymirror@simple#1\tikz@stop}, + xmirror/.code={\pgfutil@ifnextchar(\tikzext@trans@xmirror@coordinate\tikzext@trans@xmirror@simple#1\tikz@stop}, + mirror x/.code={% + \pgfextract@process\tikz@temp{\tikz@scan@one@point\pgfutil@firstofone#1\relax}% + \edef\tikz@marshal{% + \noexpand\tikz@addtransform{% + \noexpand\pgftransformmirror + {\expandafter\noexpand\tikz@temp} + {\noexpand\pgfpointadd{\expandafter\noexpand\tikz@temp} + {\noexpand\pgfqpointxy{0}{1}}}}}% + \tikz@marshal + }, + mirror y/.code={% + \pgfextract@process\tikz@temp{\tikz@scan@one@point\pgfutil@firstofone#1\relax}% + \edef\tikz@marshal{% + \noexpand\tikz@addtransform{% + \noexpand\pgftransformmirror + {\expandafter\noexpand\tikz@temp} + {\noexpand\pgfpointadd{\expandafter\noexpand\tikz@temp} + {\noexpand\pgfqpointxy{1}{0}}}}}% + \tikz@marshal + }, + mirror/.value required, + ymirror/.default=+0pt, + xmirror/.default=+0pt, + mirror x/.default={(0,0)}, + mirror y/.default={(0,0)}% +} +\def\tikzext@trans@mirror#1--#2\tikz@stop{% + \tikz@addtransform{% + \pgftransformmirror{\tikz@scan@one@point\pgfutil@firstofone#1\relax} + {\tikz@scan@one@point\pgfutil@firstofone#2\relax}}} +\def\tikzext@trans@xmirror@simple#1\tikz@stop{\tikz@addtransform{\pgftransformxmirror{#1}}} +\def\tikzext@trans@ymirror@simple#1\tikz@stop{\tikz@addtransform{\pgftransformymirror{#1}}} +\def\tikzext@trans@xmirror@coordinate#1\tikz@stop{% + \tikz@scan@one@point\pgfutil@firstofone#1\relax + \edef\tikz@marshal{% + \noexpand\tikz@addtransform{% + \noexpand\pgftransformxmirror{+\the\pgf@x}% + }% + }% + \tikz@marshal +} +\def\tikzext@trans@ymirror@coordinate#1\tikz@stop{% + \tikz@scan@one@point\pgfutil@firstofone#1\relax + \edef\tikz@marshal{% + \noexpand\tikz@addtransform{% + \noexpand\pgftransformymirror{+\the\pgf@y}% + }% + }% + \tikz@marshal +} + +\tikzset{ + Mirror/.code={% + \pgfutil@in@{--}{#1}% + \ifpgfutil@in@ + \tikzext@trans@Mirror#1\tikz@stop + \else + \tikz@addtransform{\tikz@scan@one@point\pgfqtransformMirror#1\relax}% + \fi}, + yMirror/.code={\pgfutil@ifnextchar(\tikzext@trans@yMirror@coordinate\tikzext@trans@yMirror@simple#1\tikz@stop}, + xMirror/.code={\pgfutil@ifnextchar(\tikzext@trans@xMirror@coordinate\tikzext@trans@xMirror@simple#1\tikz@stop}, + Mirror x/.code={% + \pgfextract@process\tikz@temp{\tikz@scan@one@point\pgfutil@firstofone#1\relax}% + \edef\tikz@marshal{% + \noexpand\tikz@addtransform{% + \noexpand\pgftransformMirror + {\expandafter\noexpand\tikz@temp} + {\noexpand\pgfpointadd{\expandafter\noexpand\tikz@temp} + {\noexpand\pgfqpointxy{0}{1}}}}}% + \tikz@marshal + }, + Mirror y/.code={% + \pgfextract@process\tikz@temp{\tikz@scan@one@point\pgfutil@firstofone#1\relax}% + \edef\tikz@marshal{% + \noexpand\tikz@addtransform{% + \noexpand\pgftransformMirror + {\expandafter\noexpand\tikz@temp} + {\noexpand\pgfpointadd{\expandafter\noexpand\tikz@temp} + {\noexpand\pgfqpointxy{1}{0}}}}}% + \tikz@marshal + }, + Mirror/.value required, + yMirror/.default=+0pt, + xMirror/.default=+0pt, + Mirror x/.default={(0,0)}, + Mirror y/.default={(0,0)}% +} +\def\tikzext@trans@Mirror#1--#2\tikz@stop{% + \tikz@addtransform{% + \pgftransformMirror{\tikz@scan@one@point\pgfutil@firstofone#1\relax} + {\tikz@scan@one@point\pgfutil@firstofone#2\relax}}} +\def\tikzext@trans@xMirror@simple#1\tikz@stop{\tikz@addtransform{\pgftransformxMirror{#1}}} +\def\tikzext@trans@yMirror@simple#1\tikz@stop{\tikz@addtransform{\pgftransformyMirror{#1}}} +\def\tikzext@trans@xMirror@coordinate#1\tikz@stop{% + \tikz@scan@one@point\pgfutil@firstofone#1\relax + \edef\tikz@marshal{% + \noexpand\tikz@addtransform{% + \noexpand\pgftransformxMirror{+\the\pgf@x}% + }% + }% + \tikz@marshal +} +\def\tikzext@trans@yMirror@coordinate#1\tikz@stop{% + \tikz@scan@one@point\pgfutil@firstofone#1\relax + \edef\tikz@marshal{% + \noexpand\tikz@addtransform{% + \noexpand\pgftransformyMirror{+\the\pgf@y}% + }% + }% + \tikz@marshal +} +\endinput |