diff options
author | Norbert Preining <norbert@preining.info> | 2024-06-04 03:03:30 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-06-04 03:03:30 +0000 |
commit | 90993506c261625fc3372503230dcd1c6d0b6f49 (patch) | |
tree | bb8957809f333d66b16ca7904f65065429c48624 /graphics/pgf/contrib/tkz-grapheur/tex/tkz-grapheur.sty | |
parent | e83ddb0c0c40cddccb9e35b6a1f83b3a70fc2b3d (diff) |
CTAN sync 202406040303
Diffstat (limited to 'graphics/pgf/contrib/tkz-grapheur/tex/tkz-grapheur.sty')
-rw-r--r-- | graphics/pgf/contrib/tkz-grapheur/tex/tkz-grapheur.sty | 215 |
1 files changed, 212 insertions, 3 deletions
diff --git a/graphics/pgf/contrib/tkz-grapheur/tex/tkz-grapheur.sty b/graphics/pgf/contrib/tkz-grapheur/tex/tkz-grapheur.sty index 3e7d949764..8fa5917f56 100644 --- a/graphics/pgf/contrib/tkz-grapheur/tex/tkz-grapheur.sty +++ b/graphics/pgf/contrib/tkz-grapheur/tex/tkz-grapheur.sty @@ -2,9 +2,10 @@ % licence : Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txtf \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{tkz-grapheur}[2024/05/28 0.1.1 Des outils en TikZ pour travailler comme avec un grapheur] +\ProvidesPackage{tkz-grapheur}[2024/05/31 0.1.2 Des outils en TikZ pour travailler comme avec un grapheur] %====HISTORIQUE +% v 0.1.2 Max/Min + Droites % v 0.1.1 Densité loi normale + khi deux + Améliorations diverses % v 0.1.0 Version initiale [fr] @@ -19,7 +20,7 @@ %====BASE \RequirePackage{tikz} \RequirePackage{ifthen} -\usetikzlibrary{calc,intersections,patterns,patterns.meta} +\usetikzlibrary{calc,intersections,patterns,patterns.meta,bbox} \RequirePackage{simplekv} \RequirePackage{xintexpr} \RequirePackage{xstring} @@ -487,7 +488,8 @@ Taillec=2pt,% Taillex=2pt,% Tailleo=1.75pt,% - Style=o + Style=o,% + Traits=false } \NewDocumentCommand\MarquerPts{ s O{} D<>{\normalfont\normalsize} m }{% %étoilée = sans label @@ -500,6 +502,11 @@ \IfStrEq{\pflstylepoints}{x}% {% \foreach \Point in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcroix={\useKV[GraphiqueTikzMarkPoints]{Taillex}}/45} ; }% }% @@ -507,6 +514,11 @@ \IfStrEq{\pflstylepoints}{+}% {% \foreach \Point in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcroix={\useKV[GraphiqueTikzMarkPoints]{Taillex}}/90} ; }% }% @@ -514,6 +526,11 @@ \IfStrEq{\pflstylepoints}{c}% {% \foreach \Point in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \filldraw[draw=none,fill={\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcarre={\useKV[GraphiqueTikzMarkPoints]{Taillec}}/0} ; }% }% @@ -521,6 +538,11 @@ \IfStrEq{\pflstylepoints}{d}% {% \foreach \Point in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \filldraw[draw=none,fill={\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcarre={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}/45} ; }% }% @@ -531,11 +553,21 @@ {% \StrCut{\pflcouleurpoints}{/}{\pflcouleurpointsA}{\pflcouleurpointsB}% \foreach \Point in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \filldraw[pfltrait,fill=\pflcouleurpointsB,draw=\pflcouleurpointsA] \Point circle[radius={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}] ; }% }% {% \foreach \Point in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \filldraw[\pflcouleurpoints] \Point circle[radius={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}] ; }% }% @@ -546,6 +578,11 @@ \IfStrEq{\pflstylepoints}{x}% {% \foreach \Point/\Label/\Pos in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcroix={\useKV[GraphiqueTikzMarkPoints]{Taillex}}/45} node[\Pos,font=#3] {\Label} ; }% }% @@ -553,6 +590,11 @@ \IfStrEq{\pflstylepoints}{+}% {% \foreach \Point/\Label/\Pos in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcroix={\useKV[GraphiqueTikzMarkPoints]{Taillex}}/90} node[\Pos,font=#3] {\Label} ; }% }% @@ -560,6 +602,11 @@ \IfStrEq{\pflstylepoints}{c}% {% \foreach \Point/\Label/\Pos in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \filldraw[draw=none,fill={\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcarre={\useKV[GraphiqueTikzMarkPoints]{Taillec}}/0} node[\Pos,{\useKV[GraphiqueTikzMarkPoints]{Couleur}},font=#3] {\Label} ; }% }% @@ -567,6 +614,11 @@ \IfStrEq{\pflstylepoints}{d}% {% \foreach \Point/\Label/\Pos in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \filldraw[draw=none,fill={\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcarre={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}/45} node[\Pos,{\useKV[GraphiqueTikzMarkPoints]{Couleur}},font=#3] {\Label} ; }% }% @@ -577,11 +629,21 @@ {% \StrCut{\pflcouleurpoints}{/}{\pflcouleurpointsA}{\pflcouleurpointsB}% \foreach \Point/\Label/\Pos in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \draw[pfltrait,\pflcouleurpointsA,fill=\pflcouleurpointsB] \Point circle[radius={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}] node[\Pos,font=#3] {\Label} ; }% }% {% \foreach \Point/\Label/\Pos in {#4} {% + \ifboolKV[GraphiqueTikzMarkPoints]{Traits}% + {% + \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ; + }% + {}% \filldraw[\pflcouleurpoints] \Point circle[radius={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}] node[\Pos,font=#3] {\Label} ; }% }% @@ -1676,4 +1738,151 @@ \end{scope} } +%====droite +\defKV[GraphiquetikzDroite]{% + Nom=\def\pfldroitename{#1} +} + +\setKVdefault[GraphiquetikzDroite]{% + Pente=false,% + Couleur=black,% + Debut={\pflxmin},% + Fin={\pflxmax},% + Nom={} +} + +\NewDocumentCommand\TracerDroite{ O{} m m D<>{} }{% + \restoreKV[GraphiquetikzDroite]% + \setKV[GraphiquetikzDroite]{#1}% + %1er point + \path #2;% + \pgfgetlastxy{\macrox}{\macroy}% + \xdef\pfldtetikzxA{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}% + \xdef\pfldtetikzyA{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}% + %2ème point si besoin + \ifboolKV[GraphiquetikzDroite]{Pente}% + {% + \xdef\pfldtepente{\xintfloateval{#3}}% + }% + {% + \path #3;% + \pgfgetlastxy{\macrox}{\macroy}% + \xdef\pfldtetikzxB{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}% + \xdef\pfldtetikzyB{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}% + \xdef\pfldtepente{\xintfloateval{(\pfldtetikzyB-\pfldtetikzyA)/(\pfldtetikzxB-\pfldtetikzxA)}}% + }% + \begin{scope} + \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ; + \xintifboolexpr{\pfldtetikzxA == \pfldtetikzxB}% + {% + \IfEq{\pfldroitename}{}% + {% + \draw[pfltrait,{\useKV[GraphiquetikzDroite]{Couleur}},#4] (\pfldtetikzxA,\pflymin) -- (\pfldtetikzxA,\pflymax) ; + }% + {% + \draw[pfltrait,{\useKV[GraphiquetikzDroite]{Couleur}},#4,name path global=\pfldroitename] (\pfldtetikzxA,\pflymin) -- (\pfldtetikzxA,\pflymax) ; + }% + }% + {% + \IfEq{\pfldroitename}{}% + {% + \draw[pfltrait,{\useKV[GraphiquetikzDroite]{Couleur}},domain={\useKV[GraphiquetikzDroite]{Debut}}:{\useKV[GraphiquetikzDroite]{Fin}},samples=2,#4] plot (\x,{\pfldtepente*(\x-\pfldtetikzxA)+\pfldtetikzyA}) ; + }% + {% + \draw[pfltrait,{\useKV[GraphiquetikzDroite]{Couleur}},domain={\useKV[GraphiquetikzDroite]{Debut}}:{\useKV[GraphiquetikzDroite]{Fin}},samples=2,name path global=\pfldroitename,#4] plot (\x,{\pfldtepente*(\x-\pfldtetikzxA)+\pfldtetikzyA}) ; + }% + }% + \end{scope} +} + +\defKV[GraphiqueTikzMinMax]{% + Pas=\def\pflminmaxstep{#1},% + Methode=\def\pflminmaxmethode{#1},% + Coeffs=\def\pflminmaxcoeffs{#1} +} +\setKVdefault[GraphiqueTikzMinMax]{% + Debut={\pflxmin},% + Fin={\pflxmax},% + Pas={},% + Tension=0.5,% + Methode=fonction,% + Coeffs=3 +} + +\NewDocumentCommand\TrouverMaximum{ O{} m O{c-max} }{% + %1=clés + %2=paramètres en fonction de [Methode] + \restoreKV[GraphiqueTikzMinMax]% + \setKV[GraphiqueTikzMinMax]{#1}% + \IfStrEq{\pflstepcurve}{}% + {% + \xdef\pflminmaxstep{\xintfloateval{((\useKV[GraphiqueTikzMinMax]{Fin})-(\useKV[GraphiqueTikzMinMax]{Debut}))/100}}% + }% + {}% + \begin{scope}[bezier bounding box,local bounding box=bbtmpmax] + \IfStrEq{\pflminmaxmethode}{fonction}% + {% + \path[draw=none,name path=curvetmpmax] plot[smooth] coordinates {% + \xintthecoords\xintfloatexpr + seq((x,#2(x)),x={\useKV[GraphiqueTikzMinMax]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzMinMax]{Fin}},{\useKV[GraphiqueTikzMinMax]{Fin}}) + \relax + }; + }% + {}% + \IfStrEq{\pflminmaxmethode}{interpo}% + {% + \path[draw=none,name path=curvetmpmax] plot[smooth,tension={\useKV[GraphiqueTikzMinMax]{Tension}}] coordinates {#2}; + }% + {}% + \IfStrEq{\pflminmaxmethode}{spline}% + {% + \GenererSpline{#2}{\pflminmaxcoeffs}[\tmpsplineminmax]% + \path[draw=none,name path=curvetmpmax] \tmpsplineminmax ; + }% + {}% + %retour + \path[name path=tmpmax] ([yshift=-0.25\pgflinewidth]bbtmpmax.north east) -- ([yshift=-0.25\pgflinewidth]bbtmpmax.north west) ; + \path[name intersections={of=curvetmpmax and tmpmax,name=#3}] ; + \coordinate (#3) at ($0.5*(#3-1)+0.5*(#3-2)+(0,0.25\pgflinewidth)$) ; + \end{scope} +} + +\NewDocumentCommand\TrouverMinimum{ O{} m O{c-min} }{% + %1=clés + %2=paramètres en fonction de [Methode] + \restoreKV[GraphiqueTikzMinMax]% + \setKV[GraphiqueTikzMinMax]{#1}% + \IfStrEq{\pflstepcurve}{}% + {% + \xdef\pflminmaxstep{\xintfloateval{((\useKV[GraphiqueTikzMinMax]{Fin})-(\useKV[GraphiqueTikzMinMax]{Debut}))/100}}% + }% + {}% + \begin{scope}[bezier bounding box,local bounding box=bbtmpmin] + \IfStrEq{\pflminmaxmethode}{fonction}% + {% + \path[draw=none,name path=curvetmpmin] plot[smooth] coordinates {% + \xintthecoords\xintfloatexpr + seq((x,#2(x)),x={\useKV[GraphiqueTikzMinMax]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzMinMax]{Fin}},{\useKV[GraphiqueTikzMinMax]{Fin}}) + \relax + }; + }% + {}% + \IfStrEq{\pflminmaxmethode}{interpo}% + {% + \path[draw=none,name path=curvetmpmin] plot[smooth,tension={\useKV[GraphiqueTikzMinMax]{Tension}}] coordinates {#2}; + }% + {}% + \IfStrEq{\pflminmaxmethode}{spline}% + {% + \GenererSpline{#2}{\pflminmaxcoeffs}[\tmpsplineminmax]% + \path[draw=none,name path=curvetmpmin] \tmpsplineminmax ; + }% + {}% + %retour + \path[name path=tmpmin] ([yshift=0.25\pgflinewidth]bbtmpmin.south east) -- ([yshift=0.25\pgflinewidth]bbtmpmin.south west) ; + \path[name intersections={of=curvetmpmin and tmpmin,name=#3}] ; + \coordinate (#3) at ($0.5*(#3-1)+0.5*(#3-2)+(0,-0.25\pgflinewidth)$) ; + \end{scope} +} + \endinput
\ No newline at end of file |