如何使用 tikz 实现以下图形?
我到目前为止的尝试是
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\draw (0,-3)--(0,3);
\draw (4,-3)--(4,3);
\draw (-.5,0)--(4.5,0);
\draw [pattern = north east lines, pattern color = black] (0,-2) rectangle (4,2);
\end{tikzpicture}
\end{document}
产生
如何增加填充矩形的对角线之间的间距?
答案1
TikZ 定义north east lines
使用
\pgfdeclarepatternformonly{north east lines}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{4pt}{4pt}}{\pgfqpoint{3pt}{3pt}}%
{
\pgfsetlinewidth{0.4pt}
\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
\pgfpathlineto{\pgfqpoint{3.1pt}{3.1pt}}
\pgfusepath{stroke}
}
其中它似乎定义了一个从第一个点到第二个点的矩形,并从第三个点开始重复。
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{patterns}
\pgfdeclarepatternformonly{my lines}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{10pt}{10pt}}{\pgfqpoint{9pt}{9pt}}%
{
\pgfsetlinewidth{0.4pt}
\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
\pgfpathlineto{\pgfqpoint{9.1pt}{9.1pt}}
\pgfusepath{stroke}
}
\begin{document}
\begin{tikzpicture}
\draw (0,-3)--(0,3);
\draw (4,-3)--(4,3);
\draw (-.5,0)--(4.5,0);
\draw [pattern = my lines, pattern color = black] (0,-2) rectangle (4,2);
\end{tikzpicture}
\end{document}