| 1 |
% tkz-obj-grids.tex |
| 2 |
% Copyright 2024 Alain Matthes |
| 3 |
% This work may be distributed and/or modified under the |
| 4 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 5 |
% of this license or (at your option) any later version. |
| 6 |
% The latest version of this license is in |
| 7 |
% http://www.latex-project.org/lppl.txt |
| 8 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 9 |
% version 2005/12/01 or later. |
| 10 |
% This work has the LPPL maintenance status “maintained”. |
| 11 |
% The Current Maintainer of this work is Alain Matthes. |
| 12 |
|
| 13 |
\def\fileversion{4.21c} |
| 14 |
\def\filedate{2024/01/16} |
| 15 |
\typeout{2024/01/16 4.21c tkz-obj-grids.tex} |
| 16 |
\makeatletter |
| 17 |
%<--------------------------------------------------------------------------–> |
| 18 |
% Setup Grid |
| 19 |
%<--------------------------------------------------------------------------–> |
| 20 |
\pgfkeys{/tkzsugrid/.cd, |
| 21 |
line width/.store in = \tkz@sug@lw, |
| 22 |
color/.store in = \tkz@sug@color, |
| 23 |
line width = \tkz@grid@lw, |
| 24 |
color = \tkz@grid@color |
| 25 |
} |
| 26 |
|
| 27 |
\def\tkzSetUpGrid{\pgfutil@ifnextchar[{\tkz@SetUpGrid}{\tkz@SetUpGrid[]}} |
| 28 |
\def\tkz@SetUpGrid[#1]{% |
| 29 |
\begingroup |
| 30 |
\pgfqkeys{/tkzsugrid}{#1} |
| 31 |
\global\let\tkz@grid@lw\tkz@sug@lw |
| 32 |
\global\let\tkz@grid@color\tkz@sug@color |
| 33 |
\endgroup |
| 34 |
} |
| 35 |
%<--------------------------------------------------------------------------–> |
| 36 |
% tkzGrid |
| 37 |
%<--------------------------------------------------------------------------–> |
| 38 |
\pgfkeys{/tkzGrid/.cd, |
| 39 |
color/.code = {\def\tkz@gd@color{#1}% |
| 40 |
\edef\tkz@gd@subcolor{% |
| 41 |
\tkz@gd@color!\tkzCoeffSubColor}}, |
| 42 |
subxstep/.store in = {\tkz@gd@subxstep}, |
| 43 |
subystep/.store in = {\tkz@gd@subystep}, |
| 44 |
ratio/.store in = {\tkz@gd@ratio}, |
| 45 |
line width/.code = {\edef\tkz@gd@lw{#1} |
| 46 |
\edef\tkz@gd@sublw{\tkz@gd@ratio\tkz@gd@lw}}, |
| 47 |
sub/.is if = tkz@gd@sub, |
| 48 |
sub/.default = true , |
| 49 |
sub = false, |
| 50 |
color = \tkz@grid@color, |
| 51 |
ratio = 0.75, |
| 52 |
subxstep = \tkz@grid@xstep, |
| 53 |
subystep = \tkz@grid@ystep, |
| 54 |
line width = \tkz@grid@lw, |
| 55 |
/tkzGrid/.search also= {/tikz}, |
| 56 |
} |
| 57 |
%<--------------------------------------------------------------------------–> |
| 58 |
\def\tkzGrid{\pgfutil@ifnextchar[{\tkz@Grid}{\tkz@Grid[]}} |
| 59 |
\def\tkz@Grid[#1]{\@ifnextchar({\tkz@@Grid[#1]}% |
| 60 |
{\tkz@@Grid[#1](\tkz@tmp@xa,\tkz@tmp@ya)(\tkz@tmp@xb,\tkz@tmp@yb)}} |
| 61 |
\def\tkz@@Grid[#1](#2,#3)(#4,#5){% |
| 62 |
\pgfqkeys{/tkzGrid}{#1} |
| 63 |
\begingroup |
| 64 |
\edef\tkz@gxa{\fpeval{(#2-\tkz@init@xorigine)/\tkz@init@xstep}} |
| 65 |
\edef\tkz@gxb{\fpeval{(#4-\tkz@init@xorigine)/\tkz@init@xstep}} |
| 66 |
\edef\tkz@gya{\fpeval{(#3-\tkz@init@yorigine)/\tkz@init@ystep}} |
| 67 |
\edef\tkz@gyb{\fpeval{(#5-\tkz@init@yorigine)/\tkz@init@ystep}} |
| 68 |
\iftkz@gd@sub% |
| 69 |
\edef\@subxstep{\fpeval{\tkz@gd@subxstep/\tkz@init@xstep}}% |
| 70 |
\edef\@subystep{\fpeval{\tkz@gd@subystep/\tkz@init@ystep}}% |
| 71 |
\draw [xstep = \@subxstep cm,% |
| 72 |
ystep = \@subystep cm,% |
| 73 |
color = \tkz@gd@subcolor,% |
| 74 |
line width = \tkzRatioLineGrid]% |
| 75 |
(\tkz@gxa,\tkz@gya) grid (\tkz@gxb,\tkz@gyb);% |
| 76 |
\fi |
| 77 |
\draw [color = \tkz@gd@color,% |
| 78 |
line width = \tkz@gd@lw]% |
| 79 |
(\tkz@gxa,\tkz@gya) grid (\tkz@gxb,\tkz@gyb);% |
| 80 |
\endgroup |
| 81 |
}% |
| 82 |
\makeatother |
| 83 |
\endinput |