3

Drawing a simple shield-shape with TikZ like:

\documentclass{article} 
\usepackage{tikz} 
\begin{document} 

\tikz \draw (0,0) --+ (0,-1)
       arc [radius=1, start angle=-180, end angle=0]
       --+ (0,1) -- cycle;

\end{document}   

I'm struggling to figure out how to divide this shape into six regions - essentially a chequer-board pattern with 3 columns and 2 rows and then fill [row 1, column 2], [row 2, column 1], [row 2, column 3] with black.

5

UPDATE: With an arbitrary number of rows and columns, and arbitrary colors.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc}
\tikzset{checkerboard/.style args={%
    with #1 rows and #2 columns and colors #3 and #4}{path picture={
    \path (path picture bounding box.north west) coordinate (tmpCBNW)
    (path picture bounding box.north east) coordinate (tmpCBNE)
    (path picture bounding box.south west) coordinate (tmpCBSW)
    ($ {1/#2}*(tmpCBNE) - {1/#2}*(tmpCBNW)$) coordinate (tmpCBX)
    ($ {1/#1}*(tmpCBSW) - {1/#1}*(tmpCBNW)$) coordinate (tmpCBY);
    \foreach \X in {1,...,#2}
{\foreach \Y [evaluate=\Y as \Z using int(\X+\Y)]in {1,...,#1}
{\ifodd\Z
 \fill[#3] ($ \X*(tmpCBX) + \Y*(tmpCBY) $) rectangle ++ ($ -1*(tmpCBX) - (tmpCBY) $) ;
\else
 \fill[#4] ($ \X*(tmpCBX) + \Y*(tmpCBY) $) rectangle ++ ($ -1*(tmpCBX) - (tmpCBY) $) ;
\fi
}}}
}}

\begin{document} 
\begin{tikzpicture}
\draw[checkerboard=with 2 rows and 3 columns and colors black and white] (0,0) --+ (0,-1)
       arc [radius=1, start angle=-180, end angle=0]
       --+ (0,1) -- cycle;
\begin{scope}[xshift=4cm]
\draw[checkerboard=with 4 rows and 3 columns and colors blue and red] (0,0) --+ (0,-1)
       arc [radius=1, start angle=-180, end angle=0]
       --+ (0,1) -- cycle;
\end{scope}
\begin{scope}[xshift=8cm]
\draw[checkerboard=with 3 rows and 7 columns and colors yellow and blue] (0,0) --+ (0,-1)
       arc [radius=1, start angle=-180, end angle=0]
       --+ (0,1) -- cycle;
\end{scope}
\end{tikzpicture}
\end{document}   

enter image description here

ORIGINAL ANSWER:

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document} 
\begin{tikzpicture}
\draw[clip] (0,0) --+ (0,-1)
       arc [radius=1, start angle=-180, end angle=0]
       --+ (0,1) -- cycle;
\foreach \X in {1,2,3}
{\foreach \Y [evaluate=\Y as \Z using int(\X+\Y)]in {1,2}
{\ifodd\Z
 \fill ({2*(\X-1)/3},{-(\Y-1)}) rectangle ({2*(\X)/3},{-\Y}) ;
\else
\fi
}}
\end{tikzpicture}
\end{document}   

enter image description here

7

You can use path picture and the corresponding path picture bounding box to draw your background.

\documentclass[tikz,border=7pt]{standalone}
\tikzset{
  chess/.style={
    path picture={
      \fill (path picture bounding box.west)
          -|(path picture bounding box.south east)
          -|(path picture bounding box.71)
          -|(path picture bounding box.251)
          -|cycle;
    }
  }
}
\begin{document}
  \tikz \draw[chess] (0,0) --+ (0,-1)
       arc [radius=1, start angle=-180, end angle=0]
       |- cycle;
\end{document}

enter image description here

NOTE: For a another shape you should adjust (path picture bounding box.71) and (path picture bounding box.251), or for a general case you can use more complicated ($(path picture bounding box.north east)!1/3!(path picture bounding box.north west)$) and ($(path picture bounding box.south east)!2/3!(path picture bounding box.south west)$) that require calc library.

NOTE 2: You can also use this path to fill directly (without path picture):

\fill (2/3,0) -| (4/3,{-1-sin(acos(1/3))})
   arc [radius=1, start angle=-acos(1/3), end angle=0]
   -- (0,-1)
   arc [radius=1, start angle=-180, end angle=-acos(-1/3)]
   -- cycle;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.