如何获得 Gordon、Webb 和 Wolpert 的图片

如何获得 Gordon、Webb 和 Wolpert 的图片

在此处输入图片描述 我对上面的图片很感兴趣,但我不知道如何绘制它。有相关资料吗?

答案1

您可以简单地创建两个pics,一个正方形(quadro在我的最小工作示例中,顺便说一下,了解如何为下一个问题构建它)和一个三角形(triang在我的 MWE 中),并使用可选的旋转参数,然后在 TikZ 中使用它们matrix

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{matrix}
\tikzset{%
    pics/quadro/.style={code={%  
            \draw[fill=cyan!90!gray] (0,0) rectangle (1,1);
    }},
    pics/triang/.style={code={%  
            \draw[fill=cyan!90!gray, rotate around={#1:(.5,.5)}] (0,0) -- (0,1) -- (1,0) -- cycle;
    }},
    pics/triang/.default=0,
    mymatrix/.style={
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth
    },
}
\begin{document} 
\begin{tikzpicture} 
\matrix[mymatrix]
{
\pic {triang={90}}; \\
\pic {triang={180}}; &\pic {quadro}; & \pic {quadro}; \\
 & & \pic {triang={270}}; \\
};
\end{tikzpicture}
\begin{tikzpicture} 
\matrix[mymatrix]
{
\pic {quadro}; \\
\pic {triang={180}}; &\pic {quadro}; & \pic {triang}; \\
 & \pic {triang={180}}; \\
};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

另一种解决方案是使用常规节点、方形节点和顶角为 90 度的等腰三角形。您可以将节点放置在绝对坐标上或使用相对定位。

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{positioning, shapes.geometric, matrix}

\begin{document}
\begin{tikzpicture}[
    right angle triangle/.style={
        isosceles triangle,
        isosceles triangle apex angle=90,
        shape border uses incircle,
        outer sep=0pt,
        anchor=apex,
        minimum width=1cm*sqrt(2),
        miter limit=1,
        fill=#1!70,
        draw=#1!80!black,
        },
    tnw/.style={
        right angle triangle=#1,
        shape border rotate=135},
    tne/.style={
        right angle triangle=#1,
        shape border rotate=45},
    tsw/.style={
        right angle triangle=#1,
        shape border rotate=-135},
    tse/.style={
        right angle triangle=#1,
        shape border rotate=-45},
    sq/.style={
        minimum size=1cm,
        outer sep=0pt,
        draw=#1!80!black,
        fill=#1!70}
    ]

\node[tse=blue] at (0,0) {};
\node[tne=blue] at (0,0) {};
\node[sq=blue, anchor=north west] at (0,0) {};
\node[sq=blue, anchor=north west] at (1,0) {};
\node[tnw=blue] at (1,-1) {};

\begin{scope}[shift={(3cm,.5cm)}, node distance=0pt]
\node[sq=red] at (0,0) (a) {};
%use positioning before node specification to keep apex anchor
\node[below=of a.south east, tne=orange] (b) {};
\node[below right=of a.south east, sq=green] (c) {};
\node[right=of c.south east, tsw=blue] (d) {};
\node[below=of c.south east, tne=brown] (e) {};
\end{scope}

\end{tikzpicture}
\end{document}

在此处输入图片描述

更新:

直角三角形和正方形的另一种样式定义可以简化和统一元素的语法和位置。这两个元素都用两个参数定义:

rat={rotation respect the apex anchor}{position of apex anchor}
sqr={rotation respect right vertex anchor}{position of right vertex anchor}

一些例子:

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{tikzpicture}[
    %right angle triangle
    rat/.style 2 args={
        isosceles triangle,
        isosceles triangle apex angle=90,
        shape border uses incircle,
        outer sep=0pt,
        anchor=apex,
        minimum width=1cm*sqrt(2),
        miter limit=1,
        fill=blue!70,
        draw=blue!80!black,
        shape border rotate=#1,
        at={#2},
        node contents={},
        },
    %the square is a kite shape 
    sqr/.style 2 args={
        kite,
        kite vertex angles=90,
%       kite lower vertex angle=90
        shape border uses incircle,
        outer sep=0pt,
        anchor=right vertex,
        minimum size=1cm*sqrt(2),
        miter limit=1,
        fill=blue!70,
        draw=blue!80!black,
        shape border rotate=#1,
        at={#2},
        node contents={},
        },
    ]

\node[rat={-45}{(0,0)}];
\node[rat={45}{(0,0)}];
\node[sqr={135}{(0,0)}];
\node[sqr={135}{(1,0)}];
\node[rat={135}{(1,-1)}];

\begin{scope}[shift={(4cm,0cm)}, node distance=0pt]
\node[sqr={-45}{(0,0)}];
\node[rat={45}{(0,0)}];
\node[sqr={135}{(0,0)}];
\node[rat={45}{(1,-1)}];
\node[rat={-135}{(1,-1)}];
\end{scope}

\begin{scope}[shift={(0cm,-3cm)}, node distance=0pt]
\node[rat={-90}{(0,0)}];
\node[rat={90}{(0,0)}];
\node[rat={180}{(0,0)}];
\node[rat={-90}{(0,-1cm*sqrt(2))}];
\node[rat={0}{(0,-1cm*sqrt(2))}];
\node[rat={180}{(0,-1cm*sqrt(2))}];
\node[rat={0}{({1cm*sqrt(2)},{-1cm*sqrt(2)})}];
\node[rat={90}{({1cm*sqrt(2)},{-1cm*sqrt(2)})}];
\end{scope}

\begin{scope}[shift={(3cm,-4cm)}, node distance=0pt]
\node[rat={45}{(0,0)}];
\node[sqr={135}{(0,0)}];
\node[sqr={135}{(1,0)}];
\node[rat={135}{(2,0)}];
\node[rat={-45}{(1,0)}];
\node[rat={-135}{(1,0)}];
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

使用 TikZ 很容易。第一张图片是:

\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
\tikz{
\definecolor{LB}{HTML}{5999D4}
\fill[LB] (-8.5,4) -- (-11.5,1) -- (-8.5,-2) -- (-5.5,-2) -- (-5.5,-5) -- (-2.5,-2) -- (-2.5,1) -- (-8.5,1) -- cycle;
\draw (-8.5,4) -- (-11.5,1) -- (-8.5,-2) -- (-5.5,-2) -- (-5.5,-5) -- (-2.5,-2) -- (-2.5,1) -- (-8.5,1) -- cycle;
\draw (-11.5,1) -- (-8.5,1) -- (-8.5,-2) (-2.5,-2) -- (-5.5,-2) -- (-5.5,1);}
\end{document}

在此处输入图片描述

答案4

这些东西可以通过使用\cliplocal bounding boxes 和网格来方便地获得。

\documentclass[tikz,border=3.14mm]{standalone}
\definecolor{dunno}{RGB}{113,154,210}
\begin{document}
\begin{tikzpicture}
 \begin{scope}[local bounding box=box1]
  \draw[clip] (0,0) -- ++(1,1) |- ++ (2,-1) -- ++ (0,-1) -- ++ (-1,-1)
  |- ++(-1,1) -- cycle;
  \fill[dunno] (box1.south west) rectangle (box1.north east);
  \draw[ultra thin] (box1.south west) grid (box1.north east);
 \end{scope}
 \begin{scope}[local bounding box=box2,xshift=4cm]
  \draw[clip] (0,0) |- ++(1,1) |- ++ (1,-1) -- ++ (1,-1) -| ++ (-1,-1) -- cycle;
  \fill[dunno] (box2.south west) rectangle (box2.north east);
  \draw[ultra thin] (box2.south west) grid (box2.north east);
 \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

或者,也许更方便的是,使用path picture

\documentclass[tikz,border=3.14mm]{standalone}
\definecolor{dunno}{RGB}{113,154,210}
\begin{document}
\begin{tikzpicture}[GWW/.style={path picture={\fill[dunno] (path picture bounding box.south west) 
  rectangle (path picture bounding box.north east);
  \draw[ultra thin] (path picture bounding box.south west) 
  grid (path picture bounding box.north east);}}]

  \draw[GWW] (0,0) -- ++(1,1) |- ++ (2,-1) -- ++ (0,-1) -- ++ (-1,-1)
  |- ++(-1,1) -- cycle;

 \begin{scope}[xshift=4cm]
  \draw[GWW] (0,0) |- ++(1,1) |- ++ (1,-1) -- ++ (1,-1) -| ++ (-1,-1) -- cycle;
 \end{scope}
\end{tikzpicture}
\end{document}

相关内容