So I want to fill a rectangle, like below, but without all the hassle of forlooping and getting coordinates.
I want a magic command that places my symbol repeatedly inside a rectangle. Preferably given a start and end coordinate
;
\automagicGrid[step size x=0.1, step size y=0.1]{(rect.south west)}{(rect.north east)}{\node{$\otimes$}}
Here is an example of a manual, terrible way to do it.
\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}
\makeatletter
\tikzset{autofit/.style={
% autofit: automagically generate awesome anchorpoints
fit={(\pgf@pathminx,\pgf@pathminy) (\pgf@pathmaxx,\pgf@pathmaxy)},
inner sep=0pt
}
}
\makeatother
% Draw my rectangle
\def\rectH{2}
\def\rectW{2}
\draw(0,0) rectangle (\rectW,\rectH) node[autofit](rect){};
% I want this command
% \automagicGrid[step size x=0.1, step size y=0.1]{(rect.south west)}{(rect.north east)}{\node{$\otimes$}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Below is what I DON'T want %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\xStart{.2}
\def\xStepSize{.3}
\edef\paddingX{.1}
\pgfmathsetmacro\xStep{\xStart+\xStepSize}
\pgfmathsetmacro\xEnd{\rectH-\paddingX}
\def\yStart{.2}
\def\yStepSize{.3}
\edef\paddingY{.1}
\pgfmathsetmacro\yStep{\yStart+\xStepSize}
\pgfmathsetmacro\yEnd{\rectH-\paddingY}
\foreach \x in {\xStart,\xStep,...,\xEnd}{
\foreach \y in {\yStart, \yStep,...,\yEnd}{
\node at (\x+\paddingX/2,\y+\paddingY/2){$\otimes$};
}
}
\end{tikzpicture}
\end{document}
And the result:
I will be happy though if someone just find a clean way to fetch said coordinates, because that's the real hassle of this.