Tikz 对角线填充图案

Tikz 对角线填充图案

我想要对角线图案,我也在文档中找到了它,但是出了点问题:

在此处输入图片描述

两种图案应由两个方向的实线组成。

新风:

\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{calc,patterns}

\begin{document}
\noindent\hrulefill

\begin{center}
\begin{tikzpicture}[
  extended line/.style={shorten >=-#1,shorten <=-#1}]
\coordinate (a) at (0,0);
\coordinate (b1) at (1,1);
\coordinate (b2) at (-1,1);
\coordinate (b3) at (-1,-1);
\coordinate (b4) at (1,-1);
\fill[pattern=north west lines]
   ($(b1)$) -- ($(b2)$) -- ($(b3)$);
\fill[pattern=north east lines]
   ($(b1)$) -- ($(b2)$) -- ($(b4)$);
\draw[extended line=1mm] (b3) -- (b1);
\draw[extended line=1mm] (b4) -- (b2);
\end{tikzpicture}
\end{center}


\noindent\hrulefill
\end{document}

编辑有趣的是:这肯定是一个错误。MEW 的图片来自 www.overleaf.com;但如果我用 (miktext 2019) 将它编译到我的文档中,我会得到

图片

质量很差(因为我想图案是用小方块制成的,而不是剪切出漂亮的“无限”图案)但至少它是应该做的。

答案1

似乎是一项工作patterns.meta,它一直在黑暗中隐现,直到最近才被添加到 pgfmanual 中。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{patterns.meta}
\begin{document}
\tikzdeclarepattern{
  name=arrows,
  type=uncolored,
  bottom left={(-.1pt,-.1pt)},
  top right={(12.1pt,8.1pt)},
  tile size={(12pt,8pt)},
  tile transformation={rotate=45},
  code={
\tikzset{x=1pt,y=1pt}
\draw [-stealth] (0,2) -- (6,2); 
\draw [-stealth] (6,6) -- (12,6); 
} }
\tikzdeclarepattern{
  name=north east stripes,
  type=uncolored,
  bottom left={(-.1pt,-.1pt)},
  top right={(12.1pt,8.1pt)},
  tile size={(12pt,8pt)},
  tile transformation={rotate=45},
  code={
\tikzset{x=1pt,y=1pt}
\draw  (0,2) -- (6,2); 
\draw  (6,6) -- (12,6); 
} }
\tikzdeclarepattern{
  name=north west stripes,
  type=uncolored,
  bottom left={(-.1pt,-.1pt)},
  top right={(12.1pt,8.1pt)},
  tile size={(12pt,8pt)},
  tile transformation={rotate=-45},
  code={
\tikzset{x=1pt,y=1pt}
\draw  (1,2) -- (5,2); 
\draw  (7,6) -- (11,6); 
} }
\begin{tikzpicture}
\draw [pattern=arrows] (-2,2) -- (0,0) -- (2,2);
\draw [pattern=north east stripes] (2,2) -- (0,0) -- (2,-2);
\draw [pattern=north west stripes] (-2,2) -- (0,0) -- (-2,-2);
\end{tikzpicture}
\end{document}

在此处输入图片描述

使用方形瓷砖可以更精确地重现屏幕截图。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{patterns.meta}
\begin{document}
\tikzdeclarepattern{name=arrows,
  type=uncolored,
  bottom left={(-.1pt,-.1pt)},
  top right={(10.1pt,10.1pt)},
  tile size={(10pt,10pt)},
  tile transformation={rotate=45},
  code={
\tikzset{x=1pt,y=1pt}
\draw [-stealth] (0,2.5) -- (5,2.5); 
\draw [-stealth] (5,7.5) -- (10,7.5); 
} }
\tikzdeclarepattern{name=north east stripes,
  type=uncolored,
  bottom left={(-.1pt,-.1pt)},
  top right={(10.1pt,10.1pt)},
  tile size={(10pt,10pt)},
  tile transformation={rotate=45},
  code={
\tikzset{x=1pt,y=1pt}
\draw  (0,2.5) -- (5,2.5) (5,7.5) -- (10,7.5); 
} }
\tikzdeclarepattern{name=north west stripes,
  type=uncolored,
  bottom left={(-.1pt,-.1pt)},
  top right={(10.1pt,10.1pt)},
  tile size={(10pt,10pt)},
  tile transformation={rotate=-45},
  code={
\tikzset{x=1pt,y=1pt}
\draw (1,2.5) -- (5,2.5)  (6,7.5) -- (10,7.5); 
} }
\begin{tikzpicture}
 \draw [pattern=arrows] (-3.2,3.2) -- (0,0) -- (3.2,3.2);
 \draw [pattern=north east stripes] (3.2,3.2) -- (0,0) -- (3.2,-3.2);
 \draw [pattern=north west stripes] (-3.2,3.2) -- (0,0) -- (-3.2,-3.2);
\end{tikzpicture}
\end{document}

在此处输入图片描述

preview我使用各种放大倍数对此进行了测试acroread,没有发现任何问题。

相关内容