diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/tkz-base/tkz-tools-utilities.tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/tkz-base/tkz-tools-utilities.tex | 338 |
1 files changed, 338 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/tkz-base/tkz-tools-utilities.tex b/Master/texmf-dist/tex/latex/tkz-base/tkz-tools-utilities.tex new file mode 100644 index 00000000000..b8e99fe4272 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tkz-base/tkz-tools-utilities.tex @@ -0,0 +1,338 @@ +% Copyright 2011 by Alain Matthes +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. + + +\def\fileversion{1.16 c} +\def\filedate{2011/06/01} + +%<--------------------------------------------------------------------------–> +\def\tkzutil@empty{} +\def\tkzutil@firstofone#1{#1} +\def\tkzutil@firstoftwo#1#2{#1} +\def\tkzutil@secondoftwo#1#2{#2} +%<--------------------------------------------------------------------------–> +\long\def\tkzutil@ifundefined#1{% + \expandafter\ifx\csname#1\endcsname\relax + \expandafter\tkzutil@firstoftwo + \else + \expandafter\tkzutil@secondoftwo + \fi} +%<--------------------------------------------------------------------------–> +%<--------------------------------------------------------------------------–> +\global\def\tkzActivOff{% +\edef\tkzTwoPtCode{\the\catcode`\:} +\edef\tkzPtExCode{\the\catcode`\!} +\edef\tkzPtVirCode{\the\catcode`\;} +\catcode`\:=12 \catcode`\!=12 \catcode`\;=12}% +\global\def\tkzActivOn{% +\catcode`\:=\tkzTwoPtCode\relax +\catcode`\!=\tkzPtExCode\relax +\catcode`\;=\tkzPtVirCode\relax +}% + +%<----------------------------– autres tools --------------------------------> +%<-------------------------- Initialisation --------------------------------> +\pgfkeys{ +/tkzsupcol/.cd, + background/.code = {\global\edef\tkz@suc@bkc{#1}},% + text/.code = {\global\edef\tkz@suc@txt{#1}}, +} +\def\tkzSetUpColors{\pgfutil@ifnextchar[{\tkz@SetUpColors}{\tkz@SetUpColors[]}} +\def\tkz@SetUpColors[#1]{% +\begingroup +\pgfkeys{% +tkzsupcol/.cd, + background = \tkz@backgroundcolor, + text = \tkz@textcolor + } +\pgfqkeys{/tkzsupcol}{#1} +\global\edef\tkz@fillcolor{\tkz@suc@bkc} +\global\edef\tkz@mainlinecolor{\tkz@suc@txt} +\global\edef\tkz@textcolor{\tkz@suc@txt} +\global\def\tkz@otherlinecolor{\tkz@suc@txt!50} +\global\edef\tkz@sua@color{\tkz@mainlinecolor} +\pagecolor{\tkz@suc@bkc} +\color{\tkz@suc@txt} + \InputIfFileExists{tkz-base.cfg}{\typeout{Local configuration file tkz-param.cfg found and used}}{\typeout{tkz-base.cfg not found} +%<--------- axes cartesian system ---------------------------------------–> +\global\edef\tkz@init@color{\tkz@textcolor} +\global\def\tkz@init@lw{0.4 pt} +\global\def\tkz@init@xlabel{$x$} +\global\def\tkz@init@ylabel{$y$} +\global\def\tkz@init@tickwd{0.8 pt} +\global\def\tkz@init@ticka{2 pt} +\global\def\tkz@init@tickb{2 pt} +\global\def\tkz@init@rightspace{.5} +\global\def\tkz@init@leftspace{0} +\global\def\tkz@init@upspace{.5} +\global\def\tkz@init@downspace{0} +\global\let\tkzmathstyle\displaystyle +\tikzset{xlabel style/.style={below=3 pt, + inner sep = 1pt, + outer sep = 0pt}} +\tikzset{xaxe style/.style ={>=latex,->}} +\tikzset{ylabel style/.style={left = 3 pt, + inner sep = 1pt, + outer sep = 0pt}} +\tikzset{yaxe style/.style ={>=latex,->}} +%<-------------------------- rep ---------------------------------------–> +\global\edef\tkz@sur@color{\tkz@mainlinecolor} +\global\edef\tkz@sur@colorlabel{\tkz@mainlinecolor} +\global\def\tkz@sur@lw{0.8 pt} +\global\def\tkz@sur@posxlabel{below=2pt} +\global\def\tkz@sur@posylabel{left=2pt} +%<-------------------------- grid ---------------------------------------–> +\global\edef\tkz@grid@color{gray} +\global\def\tkz@grid@lw{0.4 pt} +\global\def\tkzCoeffSubColor{50} +\global\def\tkzCoeffSubLw{0.8} +\global\def\tkz@grid@xstep{0.2} +\global\def\tkz@grid@ystep{0.2} +%<-------------------------- line ---------------------------------------–> +\global\edef\tkz@euc@linecolor{\tkz@mainlinecolor} +\global\def\tkz@euc@linewidth{0.6pt} +\global\def\tkz@euc@linestyle{solid} +\global\def\tkz@euc@lineleft{.2} +\global\def\tkz@euc@lineright{.2} +\global\def\tkz@legend@line@len{1cm} +\global\edef\tkz@euc@segmentcolor{\tkz@mainlinecolor} +\global\edef\tkz@euc@circlecolor{\tkz@mainlinecolor} +\tikzset{line style/.style={% + line width = \tkz@euc@linewidth, + color = \tkz@euc@linecolor, + style = \tkz@euc@linestyle, + add = {\tkz@euc@lineleft} and {\tkz@euc@lineright}}} +%<-------------------------- points -----------------------------------–> +\global\edef\tkz@euc@pointshape{circle} +\global\edef\tkz@euc@pointcolor{\tkz@mainlinecolor} +\global\edef\tkz@euc@labelcolor{\tkz@mainlinecolor} +\global\def\tkz@euc@pointsize{6} +\global\def\tkz@euc@pointpos{below right} +\tikzset{point style/.style={draw = \tkz@euc@pointcolor, + inner sep = 0pt, + shape = \tkz@euc@pointshape, + minimum size = \tkz@euc@pointsize*\pgflinewidth, + fill = \tkz@euc@pointcolor!50}} +%<---------------------------- mark -----------------------------------–> +\global\edef\tkz@mk@color{\tkz@mainlinecolor} +\global\edef\tkz@mk@mark{*} +\global\edef\tkz@mk@size{3pt} +\global\edef\tkz@mk@fill{\tkz@otherlinecolor} +\tikzset{mark style/.style={mark=\tkz@mk@mark,mark size=\tkz@mk@size,mark options={color=\tkz@mk@color,fill=\tkz@mk@fill}}} +\tikzset{arrow coord style/.style={dashed, + \tkz@euc@linecolor, + >=latex', + ->}} +\tikzset{xcoord style/.style={\tkz@euc@labelcolor, + font=\normalsize,text height=1ex, + inner sep = 0pt, + outer sep = 0pt, + fill=\tkz@fillcolor, + below=3pt}} +\tikzset{ycoord style/.style={\tkz@euc@labelcolor, + font=\normalsize,text height=1ex, + inner sep = 0pt, + outer sep = 0pt, + fill=\tkz@fillcolor, + left=3pt}} +%<--------------------------- vector --------------------------------------–> +\tikzset{vector style/.style={>=latex,->}} +%<------------------------- compass -----------------------------------–> +\global\edef\tkz@euc@compasscolor{\tkz@otherlinecolor} +\global\def\tkz@euc@compasswidth{0.4pt} +\global\def\tkz@euc@compassstyle{solid} +\tikzset{compass style/.style={color = \tkz@euc@compasscolor, + line width = \tkz@euc@compasswidth, + style = \tkz@euc@compassstyle}} +} +\endgroup} + +%<--------------------------------------------------------------------------–> +% Pour savoir le nombre de décimales d'un nombre +% le nombre dans #1 et le résultat dans \c@pgfmath@countb +%<--------------------------------------------------------------------------–> + +\newcommand*\tkz@getdecimal[1]{% + \expandafter\@getdecimal#1.\@nil +} + +\def\@getdecimal#1.#2\@nil{% + \ifx\empty#2\empty + % Si #2 est vide, c'est qu'il n'y avait pas de point + % dans la chaîne initiale + \c@pgfmath@countb0 % + \global\def\tkz@decpart{}% + \else + % sinon c'est la chaîne qui suit le point décimal... + \CountToken{#2}% + % ... y compris le point en trop ajouté par \tkz@getdecimal :-) + \advance\c@pgfmath@countb by-1 % + \@@getdecimal#2\@nil + \fi +} +\def\@@getdecimal#1.\@nil{\global\def\tkz@decpart{#1}} +%<--------------------------------------------------------------------------–> +% code from JCC modifi +\newcommand\CountToken[1]{% + \c@pgfmath@countb0 % + \expandafter\C@untToken#1\@nil +%modifi ajout du expandafter +} +\newcommand\C@untToken{% + \afterassignment\C@untT@ken\let\CurrT@ken= +} +\newcommand\C@untT@ken{% + \ifx\CurrT@ken\@nil \else + \advance\c@pgfmath@countb by1 % + \expandafter\C@untToken + \fi +} +% end code from JCC + +%<–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––> +% Tools +%<–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––> +%<–––––––– code from TeX in Practice ––––––––> +\newif\if@TestSubString +\def\SubStringConditional #1#2{% + TT\fi + \edef\@MainString{#1}% + \edef\@SubStringConditionalTemp{{#1}{#2}}% + \expandafter\@SubStringConditional\@SubStringConditionalTemp +} +\def\@SubStringConditional #1#2{% + \def\@TestSubS ##1#2##2\\{% + \def\@TestTemp{##1}% + }% + \@TestSubS #1#2\\ + \ifx\@MainString\@TestTemp + \@TestSubStringfalse + \else + \@TestSubStringtrue + \fi + \if@TestSubString +} + +\def\RecursionMacroEnd #1#2#3{% + #1\relax + \def\@RecursionMacroEndNext{#2}% + \else + \def\@RecursionMacroEndNext{#3}% + \fi + \@RecursionMacroEndNext +} + +\def\ReplaceSubStrings #1#2#3#4{% + \def\@ReplaceResult{#1}% + \edef\@ReplaceMain{#2}% + \edef\@ReplaceSub{#3}% + \edef\@ReplaceSubRep{#4}% + \@ReplaceSubStrings +} +\def\@ReplaceSubStrings{% + \RecursionMacroEnd + {\if\SubStringConditional{\@ReplaceMain}{\@ReplaceSub}}% + {\@ReplaceSubStringsDo}{\expandafter\edef\@ReplaceResult{\@ReplaceMain}}% +} +\def\@ReplaceSubStringsDoX{% + \def\@ReplaceSubStringsDoA ##1% +}% +\def\@ReplaceSubStringsDo{% + \expandafter\@ReplaceSubStringsDoX \@ReplaceSub + ##2\@EndReplaceSubStrings{% + \edef\@ReplaceMain{##1\@ReplaceSubRep ##2}% + }% + \expandafter\@ReplaceSubStringsDoA\@ReplaceMain + \@EndReplaceSubStrings + \@ReplaceSubStrings +} +\def\tkzPrintFrac#1#2{% +\begingroup +\tkzReducFrac{#1}{#2} +\global\edef\tkzprintfrac{$ \frac{\tkzMathFirstResult}{\tkzMathSecondResult}$}% + \ifnum\tkzMathFirstResult=0% + \global\edef\tkzprintfrac{$0$}% + \else + \ifnum\tkzMathSecondResult=1 % + \ifnum\tkzMathFirstResult=1 % + \global\edef\tkzprintfrac{$1$}% + \else + \ifnum\tkzMathFirstResult=-1% + \global\edef\tkzprintfrac{$-1$}% + \else + \global\edef\tkzprintfrac{$\tkzMathFirstResult$}% + \fi\fi + \else + \ifnum\tkzMathFirstResult=1 % + \global\edef\tkzprintfrac{$\tkzmathstyle\frac{1}{\tkzMathSecondResult}$}% + \else + \ifnum\tkzMathFirstResult=-1 % + \global\edef\tkzprintfrac{$\tkzmathstyle\frac{-1}{\tkzMathSecondResult}$}% + \else + \global\edef\tkzprintfrac{$\tkzmathstyle\frac{\tkzMathFirstResult}{% + \tkzMathSecondResult}$}% + \fi\fi\fi\fi +\endgroup} +%<---------------------------------------------------------------------------> +\def\tkzPrintFracWithPi#1#2{% +\begingroup +\tkzReducFrac{#1}{#2} +\global\edef\tkzprintfrac{$\tkzmathstyle\frac{\tkzMathFirstResult\pi}{\tkzMathSecondResult}$}% + \ifnum\tkzMathFirstResult=0% + \global\edef\tkzprintfrac{$0$}% + \else + \ifnum\tkzMathSecondResult=1 % + \ifnum\tkzMathFirstResult=1 % + \global\edef\tkzprintfrac{$\pi$}% + \else + \ifnum\tkzMathFirstResult=-1% + \global\edef\tkzprintfrac{$-\pi$}% + \else + \global\edef\tkzprintfrac{$\tkzMathFirstResult\pi$}% + \fi\fi + \else + \ifnum\tkzMathFirstResult=1 % + \global\edef\tkzprintfrac{$\tkzmathstyle\frac{\pi}{\tkzMathSecondResult}$}% + \else + \ifnum\tkzMathFirstResult=-1 % + \global\edef\tkzprintfrac{$\tkzmathstyle\frac{-\pi}{\tkzMathSecondResult}$}% + \else + \global\edef\tkzprintfrac{$\tkzmathstyle\frac{\tkzMathFirstResult\pi}{% + \tkzMathSecondResult}$}% + \fi\fi\fi\fi +\endgroup}% + +%<---------------------------------------------------------------------------> +% chargement des modules +\def\tkz@obj@all{polygons,vectors,arcs,sectors,angles,protractor} +\def\tkz@obj@txt{all} +\def\usetkzobj{\pgfutil@ifnextchar[{\use@usetkzobj}{\use@@usetkzobj}}%} +\def\use@usetkzobj[#1]{\use@@usetkzobj{#1}} +\def\use@@usetkzobj#1{% + \def\tkz@list{#1} + \ifx\tkz@obj@txt\tkz@list \edef\tkz@list{\tkz@obj@all}% + \else + \edef\tkz@list{#1}% + \fi + %\edef\tkz@list{#1}% + \pgfutil@for\tkz@temp:=\tkz@list\do{% + \expandafter\ifx\csname tkz@library@\tkz@temp @loaded\endcsname\relax% + \expandafter\global\expandafter\let\csname tkz@library@\tkz@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\edef\csname tkz@obj@#1@atcode\endcsname{\the\catcode`\@} + \expandafter\edef\csname tkz@obj@#1@barcode\endcsname{\the\catcode`\|} + \catcode`\@=11 + \catcode`\|=12 + \input tkz-obj-\tkz@temp.tex + \catcode`\@=\csname tkz@obj@#1@atcode\endcsname + \catcode`\|=\csname tkz@obj@#1@barcode\endcsname + \fi% + }% +}% +\def\DisabledNumprint{\let\tkz@numprint\numprint +\let\numprint\relax} +\def\EnabledNumprint{\let\numprint\tkz@numprint} +\endinput
\ No newline at end of file |