| 1 |
% tkz-obj-eu-grids.tex |
| 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-obj-eu-grids.tex} |
| 7 |
\makeatletter |
| 8 |
%<--------------------------------------------------------------------------–> |
| 9 |
% Setup Grid |
| 10 |
%<--------------------------------------------------------------------------–> |
| 11 |
\pgfkeys{/tkzsugrid/.cd, |
| 12 |
line width/.store in = \tkz@sug@lw, |
| 13 |
color/.store in = \tkz@sug@color, |
| 14 |
line width = \tkz@grid@lw, |
| 15 |
color = \tkz@grid@color |
| 16 |
} |
| 17 |
|
| 18 |
\def\tkzSetUpGrid{\pgfutil@ifnextchar[{\tkz@SetUpGrid}{\tkz@SetUpGrid[]}} |
| 19 |
\def\tkz@SetUpGrid[#1]{% |
| 20 |
\begingroup |
| 21 |
\pgfqkeys{/tkzsugrid}{#1} |
| 22 |
\global\let\tkz@grid@lw\tkz@sug@lw |
| 23 |
\global\let\tkz@grid@color\tkz@sug@color |
| 24 |
\endgroup |
| 25 |
} |
| 26 |
%<--------------------------------------------------------------------------–> |
| 27 |
% tkzGrid |
| 28 |
%<--------------------------------------------------------------------------–> |
| 29 |
\pgfkeys{/tkzGrid/.cd, |
| 30 |
color/.code = {\def\tkz@gd@color{#1}% |
| 31 |
\edef\tkz@gd@subcolor{% |
| 32 |
\tkz@gd@color!\tkzCoeffSubColor}}, |
| 33 |
subxstep/.store in = {\tkz@gd@subxstep}, |
| 34 |
subystep/.store in = {\tkz@gd@subystep}, |
| 35 |
ratio/.store in = {\tkz@gd@ratio}, |
| 36 |
line width/.code = {\edef\tkz@gd@lw{#1} |
| 37 |
\edef\tkz@gd@sublw{\tkz@gd@ratio\tkz@gd@lw}}, |
| 38 |
sub/.is if = tkz@gd@sub, |
| 39 |
sub/.default = true , |
| 40 |
sub = false, |
| 41 |
color = \tkz@grid@color, |
| 42 |
ratio = 0.75, |
| 43 |
subxstep = \tkz@grid@xstep, |
| 44 |
subystep = \tkz@grid@ystep, |
| 45 |
line width = \tkz@grid@lw, |
| 46 |
/tkzGrid/.search also= {/tikz}, |
| 47 |
} |
| 48 |
%<--------------------------------------------------------------------------–> |
| 49 |
\def\tkzGrid{\pgfutil@ifnextchar[{\tkz@Grid}{\tkz@Grid[]}} |
| 50 |
\def\tkz@Grid[#1]{\@ifnextchar({\tkz@@Grid[#1]}% |
| 51 |
{\tkz@@Grid[#1](\tkz@tmp@xa,\tkz@tmp@ya)(\tkz@tmp@xb,\tkz@tmp@yb)}} |
| 52 |
\def\tkz@@Grid[#1](#2,#3)(#4,#5){% |
| 53 |
\pgfqkeys{/tkzGrid}{#1} |
| 54 |
\begingroup |
| 55 |
\edef\tkz@gxa{\fpeval{(#2-\tkz@init@xorigine)/\tkz@init@xstep}} |
| 56 |
\edef\tkz@gxb{\fpeval{(#4-\tkz@init@xorigine)/\tkz@init@xstep}} |
| 57 |
\edef\tkz@gya{\fpeval{(#3-\tkz@init@yorigine)/\tkz@init@ystep}} |
| 58 |
\edef\tkz@gyb{\fpeval{(#5-\tkz@init@yorigine)/\tkz@init@ystep}} |
| 59 |
\iftkz@gd@sub% |
| 60 |
\edef\@subxstep{\fpeval{\tkz@gd@subxstep/\tkz@init@xstep}}% |
| 61 |
\edef\@subystep{\fpeval{\tkz@gd@subystep/\tkz@init@ystep}}% |
| 62 |
\draw [xstep = \@subxstep cm,% |
| 63 |
ystep = \@subystep cm,% |
| 64 |
color = \tkz@gd@subcolor,% |
| 65 |
line width = \tkzRatioLineGrid]% |
| 66 |
(\tkz@gxa,\tkz@gya) grid (\tkz@gxb,\tkz@gyb);% |
| 67 |
\fi |
| 68 |
\draw [color = \tkz@gd@color,% |
| 69 |
line width = \tkz@gd@lw]% |
| 70 |
(\tkz@gxa,\tkz@gya) grid (\tkz@gxb,\tkz@gyb);% |
| 71 |
\endgroup |
| 72 |
}% |
| 73 |
\makeatother |
| 74 |
\endinput |