[Tex/LaTex] Tikz custom dotted pattern

patterntikz-pgf

I have no idea for reducing distance of dots (lines) in tikz dotted (horizontal lines) pattern.
I find some similar examples in this website (like this), but it was so complicated. Can someone give me some hints?

Best Answer

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{patterns}

\pgfdeclarepatternformonly{mydots}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{1pt}{1pt}}{\pgfqpoint{2pt}{2pt}}% original definition: \pgfqpoint{3pt}{3pt}
{%
  \pgfpathcircle{\pgfqpoint{0pt}{0pt}}{.5pt}%
  \pgfusepath{fill}%
}%

\pgfdeclarepatternformonly{mynewdots}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{1pt}{1pt}}{\pgfqpoint{1pt}{1pt}}% original definition: \pgfqpoint{3pt}{3pt}
{%
  \pgfpathcircle{\pgfqpoint{0pt}{0pt}}{.5pt}%
  \pgfusepath{fill}%
}%

\begin{document}
\begin{tikzpicture}
\draw[pattern=dots] (0,0) rectangle ++(3,3);
\draw[pattern=mydots] (4,0) rectangle ++(3,3);
\draw[pattern=mynewdots] (8,0) rectangle ++(3,3);
\end{tikzpicture}
\end{document}

enter image description here

Related Question