绘制彩色瓷砖

绘制彩色瓷砖

我怎样才能制作出任意大小的正方形? 彩色方块

我一直在研究 skak,但找不到没有生成整个棋盘的例子。

我知道我以前在某个地方见过这个,但我记不起用英语如何描述这个。

答案1

除非你使用特定于国际象棋的东西,否则我会使用蒂克兹而不是斯卡克. 基本思想蒂克兹是使用\draw带有 xy 坐标的命令。以下是生成阴影 2x2 正方形的一种方法:

\documentclass{article}
\usepackage{tikz}

% \BackSquares{ list of south west coordinates of squares to fill }
\newcommand\BlackSquares[1]{
  \begin{tikzpicture}
    \draw[ultra thick](0,0) rectangle (2,2);
    \draw[ultra thick](0,1)--(2,1);
    \draw[ultra thick](1,0)--(1,2);
    \foreach \sq in {#1} {\draw[fill=black]\sq rectangle ++(1,1);}
  \end{tikzpicture}
}

\begin{document}
  \BlackSquares{{(0,0)},{(1,0)}}
  \BlackSquares{{(0,0)},{(0,1)}}
  \BlackSquares{{(0,0)},{(1,1)}}
  \BlackSquares{{(1,0)},{(0,1)}}
\end{document}

该 MWE 产生:在此处输入图片描述

相关内容