| 1 |
% tkz-tools-eu-utilities |
| 2 |
% Copyright 2011-2026 Alain Matthes |
| 3 |
% SPDX-License-Identifier: LPPL-1.3c |
| 4 |
% Maintainer: Alain Matthes |
| 5 |
|
| 6 |
\typeout{2026/01/25 5.13c tkz-tools-eu-utilities.tex} |
| 7 |
\makeatletter |
| 8 |
\pgfkeys{/tkzClip/.cd, |
| 9 |
space/.store in = {\tkz@CLI@space}, |
| 10 |
space = {}} |
| 11 |
|
| 12 |
\def\tkzClip{\pgfutil@ifnextchar[{\tkz@Clip}{\tkz@Clip[]}} |
| 13 |
\def\tkz@Clip[#1]{% |
| 14 |
|
| 15 |
\pgfqkeys{/tkzClip}{#1} |
| 16 |
\ifx\tkzutil@empty\tkz@CLI@space |
| 17 |
\clip (\tkz@xa,\tkz@ya) rectangle (\tkz@xb,\tkz@yb); |
| 18 |
\else |
| 19 |
\edef\tkz@xxa{\fpeval{\tkz@xa-\tkz@CLI@space}} |
| 20 |
\edef\tkz@yya{\fpeval{\tkz@ya-\tkz@CLI@space}} |
| 21 |
\edef\tkz@xxb{\fpeval{\tkz@xb+\tkz@CLI@space}} % correction bug 2020 |
| 22 |
\edef\tkz@yyb{\fpeval{\tkz@yb+\tkz@CLI@space}} |
| 23 |
\clip (\tkz@xxa,\tkz@yya) rectangle (\tkz@xxb,\tkz@yyb); |
| 24 |
\fi |
| 25 |
} |
| 26 |
|
| 27 |
% for testing results |
| 28 |
\def\extractxy#1{% |
| 29 |
\pgfextractx{\pgf@x}{\pgfpointanchor{#1}{center}} |
| 30 |
\pgfextracty{\pgf@y}{\pgfpointanchor{#1}{center}} |
| 31 |
} |
| 32 |
%<-------------- some tools -------------------------------------------------> |
| 33 |
\def\tkzutil@empty{} |
| 34 |
\def\tkzutil@firstofone#1{#1} |
| 35 |
\def\tkzutil@firstoftwo#1#2{#1} |
| 36 |
\def\tkzutil@secondoftwo#1#2{#2} |
| 37 |
%<--------------------------------------------------------------------------–> |
| 38 |
\long\def\tkzutil@ifundefined#1{% |
| 39 |
\expandafter\ifx\csname#1\endcsname\relax |
| 40 |
\expandafter\tkzutil@firstoftwo |
| 41 |
\else |
| 42 |
\expandafter\tkzutil@secondoftwo |
| 43 |
\fi} |
| 44 |
%<--------------------------------------------------------------------------–> |
| 45 |
\long\def\iftkznodedefined#1#2#3{% |
| 46 |
\tkzutil@ifundefined{pgf@sh@ns@#1}{#3}{#2}% |
| 47 |
} |
| 48 |
%<--------------------------------------------------------------------------–> |
| 49 |
\gdef\tkzActivOff{% |
| 50 |
\edef\tkzTwoPtCode{\the\catcode`\:} |
| 51 |
\edef\tkzPtExCode{\the\catcode`\!} |
| 52 |
\edef\tkzPtVirCode{\the\catcode`\;} |
| 53 |
\catcode`\:=12 \catcode`\!=12 \catcode`\;=12 |
| 54 |
}% |
| 55 |
\gdef\tkzActivOn{% |
| 56 |
\catcode`\:=\tkzTwoPtCode\relax |
| 57 |
\catcode`\!=\tkzPtExCode\relax |
| 58 |
\catcode`\;=\tkzPtVirCode\relax |
| 59 |
}% |
| 60 |
%<--------------------------------------------------------------------------–> |
| 61 |
% Pour savoir le nombre de décimales d'un nombre |
| 62 |
% le nombre dans #1 et le résultat dans \c@pgfmath@countb |
| 63 |
%<--------------------------------------------------------------------------–> |
| 64 |
\newcommand\tkz@getdecimal[1]{\expandafter\@getdecimal#1.\@nil} |
| 65 |
\def\@getdecimal#1.#2\@nil{% |
| 66 |
\ifx\empty#2\empty |
| 67 |
% Si #2 est vide, c'est qu'il n'y avait pas de point |
| 68 |
% dans la chaîne initiale |
| 69 |
\c@pgfmath@countb0 % |
| 70 |
\gdef\tkz@decpart{}% |
| 71 |
\else |
| 72 |
% sinon c'est la chaîne qui suit le point décimal... |
| 73 |
\CountToken{#2}% |
| 74 |
% ... y compris le point en trop ajouté par \tkz@getdecimal :-) |
| 75 |
\advance\c@pgfmath@countb by-1 % |
| 76 |
\@@getdecimal#2\@nil |
| 77 |
\fi |
| 78 |
} |
| 79 |
\def\@@getdecimal#1.\@nil{\gdef\tkz@decpart{#1}} |
| 80 |
%<---------------------------------------------------------–> |
| 81 |
% code from JCC modifi |
| 82 |
\newcommand\CountToken[1]{% |
| 83 |
\c@pgfmath@countb0 % |
| 84 |
\expandafter\C@untToken#1\@nil |
| 85 |
%modifi ajout du expandafter |
| 86 |
} |
| 87 |
\newcommand\C@untToken{% |
| 88 |
\afterassignment\C@untT@ken\let\CurrT@ken= |
| 89 |
} |
| 90 |
\newcommand\C@untT@ken{% |
| 91 |
\ifx\CurrT@ken\@nil \else |
| 92 |
\advance\c@pgfmath@countb by1 % |
| 93 |
\expandafter\C@untToken |
| 94 |
\fi |
| 95 |
} |
| 96 |
%<---------------------------------------------------------–> |
| 97 |
\def\tkz@recuplast(#1,#2){\def\tkz@last{#1}} |
| 98 |
\def\tkz@stop{\tkz@stop} |
| 99 |
% end code from JCC |
| 100 |
%<---------------------------------------------------------–> |
| 101 |
% Tools |
| 102 |
%<---------------------------------------------------------–> |
| 103 |
%<–––––––– code from TeX in Practice ––––––––> |
| 104 |
\def\SubStringConditional #1#2{% |
| 105 |
TT\fi |
| 106 |
\edef\@MainString{#1}% |
| 107 |
\edef\@SubStringConditionalTemp{{#1}{#2}}% |
| 108 |
\expandafter\@SubStringConditional\@SubStringConditionalTemp |
| 109 |
} |
| 110 |
\def\@SubStringConditional #1#2{% |
| 111 |
\def\@TestSubS ##1#2##2\\{% |
| 112 |
\def\@TestTemp{##1}% |
| 113 |
}% |
| 114 |
\@TestSubS #1#2\\ |
| 115 |
\ifx\@MainString\@TestTemp |
| 116 |
\tkz@TestSubStringfalse |
| 117 |
\else |
| 118 |
\tkz@TestSubStringtrue |
| 119 |
\fi |
| 120 |
\iftkz@TestSubString |
| 121 |
} |
| 122 |
\def\RecursionMacroEnd #1#2#3{% |
| 123 |
#1\relax |
| 124 |
\def\@RecursionMacroEndNext{#2}% |
| 125 |
\else |
| 126 |
\def\@RecursionMacroEndNext{#3}% |
| 127 |
\fi |
| 128 |
\@RecursionMacroEndNext |
| 129 |
} |
| 130 |
\def\ReplaceSubStrings #1#2#3#4{% |
| 131 |
\def\@ReplaceResult{#1}% |
| 132 |
\edef\@ReplaceMain{#2}% |
| 133 |
\edef\@ReplaceSub{#3}% |
| 134 |
\edef\@ReplaceSubRep{#4}% |
| 135 |
\@ReplaceSubStrings |
| 136 |
} |
| 137 |
\def\@ReplaceSubStrings{% |
| 138 |
\RecursionMacroEnd |
| 139 |
{\if\SubStringConditional{\@ReplaceMain}{\@ReplaceSub}}% |
| 140 |
{\@ReplaceSubStringsDo}{\expandafter\edef\@ReplaceResult{\@ReplaceMain}}% |
| 141 |
} |
| 142 |
\def\@ReplaceSubStringsDoX{% |
| 143 |
\def\@ReplaceSubStringsDoA ##1% |
| 144 |
}% |
| 145 |
\def\@ReplaceSubStringsDo{% |
| 146 |
\expandafter\@ReplaceSubStringsDoX \@ReplaceSub |
| 147 |
##2\@EndReplaceSubStrings{% |
| 148 |
\edef\@ReplaceMain{##1\@ReplaceSubRep ##2}% |
| 149 |
}% |
| 150 |
\expandafter\@ReplaceSubStringsDoA\@ReplaceMain |
| 151 |
\@EndReplaceSubStrings |
| 152 |
\@ReplaceSubStrings |
| 153 |
} |
| 154 |
%<---------------------------------------------------------–> |
| 155 |
\def\DisabledNumprint{% |
| 156 |
\let\tkz@numprint\numprint |
| 157 |
\let\numprint\relax |
| 158 |
} |
| 159 |
\def\EnabledNumprint{\let\numprint\tkz@numprint} |
| 160 |
%<---------------------------------------------------------–> |
| 161 |
|
| 162 |
%<---------------------------------------------------------–> |
| 163 |
\def\tkzHelpGrid{% |
| 164 |
\draw[help lines] (current bounding box.south west) grid |
| 165 |
(current bounding box.north east); |
| 166 |
} |
| 167 |
|
| 168 |
\makeatother |
| 169 |
\endinput |