我不知道如何减少 tikz 虚线(水平线)图案中点(线)的距离。我在这个网站上找到了一些类似的例子(比如这),但是太复杂了。有人能给我一些提示吗?
答案1
\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}