| 1 |
%% |
| 2 |
%% This is file `tikz-truchet.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% tikz-truchet.dtx (with options: `truchet') |
| 8 |
%% Copyright (c) 2019 Matthew Scroggs |
| 9 |
%% |
| 10 |
%% Permission is hereby granted, free of charge, to any person obtaining a copy |
| 11 |
%% of this software and associated documentation files (the "Software"), to deal |
| 12 |
%% in the Software without restriction, including without limitation the rights |
| 13 |
%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 14 |
%% copies of the Software, and to permit persons to whom the Software is |
| 15 |
%% furnished to do so, subject to the following conditions: |
| 16 |
%% |
| 17 |
%% The above copyright notice and this permission notice shall be included in all |
| 18 |
%% copies or substantial portions of the Software. |
| 19 |
%% |
| 20 |
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 21 |
%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 22 |
%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 23 |
%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 24 |
%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 25 |
%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 26 |
%% SOFTWARE. |
| 27 |
%% |
| 28 |
|
| 29 |
\NeedsTeXFormat{LaTeX2e} |
| 30 |
\ProvidesPackage{tikz-truchet}[2019/02/12 tikz-truchet] |
| 31 |
|
| 32 |
\RequirePackage{tikz} |
| 33 |
\RequirePackage{ifthen} |
| 34 |
|
| 35 |
\tikzset{x=2cm,y=2cm,line cap=round,line join=round, every picture} |
| 36 |
\newcommand{\truchetsquare}[6][(0,0)]{ |
| 37 |
\begin{scope}[shift={#1}] |
| 38 |
\ifthenelse{\equal{#2}{b}}{ |
| 39 |
\draw[black,fill=black] (0,0) rectangle (1,1); |
| 40 |
}{ |
| 41 |
\draw[white,fill=white] (0,0) rectangle (1,1); |
| 42 |
} |
| 43 |
\ifthenelse{\equal{#3}{#2}}{}{ |
| 44 |
\ifthenelse{\equal{#3}{b}}{ |
| 45 |
\draw [black,fill=black,domain=0:90,line width=1pt] plot ({0.5*cos(\x)}, {1-0.5*sin(\x)}) -- (0,1) -- cycle; |
| 46 |
}{ |
| 47 |
\draw [white,fill=white,domain=0:90,line width=1pt] plot ({0.5*cos(\x)}, {1-0.5*sin(\x)}) -- (0,1) -- cycle; |
| 48 |
} |
| 49 |
} |
| 50 |
\ifthenelse{\equal{#4}{#2}}{}{ |
| 51 |
\ifthenelse{\equal{#4}{b}}{ |
| 52 |
\draw [black,fill=black,domain=0:90,line width=1pt] plot ({1-0.5*cos(\x)}, {1-0.5*sin(\x)}) -- (1,1) -- cycle; |
| 53 |
}{ |
| 54 |
\draw [white,fill=white,domain=0:90,line width=1pt] plot ({1-0.5*cos(\x)}, {1-0.5*sin(\x)}) -- (1,1) -- cycle; |
| 55 |
} |
| 56 |
} |
| 57 |
\ifthenelse{\equal{#5}{#2}}{}{ |
| 58 |
\ifthenelse{\equal{#5}{b}}{ |
| 59 |
\draw [black,fill=black,domain=0:90,line width=1pt] plot ({1-0.5*cos(\x)}, {0.5*sin(\x)}) -- (1,0) -- cycle; |
| 60 |
}{ |
| 61 |
\draw [white,fill=white,domain=0:90,line width=1pt] plot ({1-0.5*cos(\x)}, {0.5*sin(\x)}) -- (1,0) -- cycle; |
| 62 |
} |
| 63 |
} |
| 64 |
\ifthenelse{\equal{#6}{#2}}{}{ |
| 65 |
\ifthenelse{\equal{#6}{b}}{ |
| 66 |
\draw [black,fill=black,domain=0:90,line width=1pt] plot ({0.5*cos(\x)}, {0.5*sin(\x)}) -- (0,0) -- cycle; |
| 67 |
}{ |
| 68 |
\draw [white,fill=white,domain=0:90,line width=1pt] plot ({0.5*cos(\x)}, {0.5*sin(\x)}) -- (0,0) -- cycle; |
| 69 |
} |
| 70 |
} |
| 71 |
\draw[black,line width=1pt] (0,0) rectangle (1,1); |
| 72 |
\end{scope} |
| 73 |
} |
| 74 |
\newcommand{\diagonalsquare}[5][(0,0)]{ |
| 75 |
\begin{scope}[shift={#1}] |
| 76 |
\draw[white,fill=white] (0,0) rectangle (1,1); |
| 77 |
\ifthenelse{\equal{#2}{b}}{ |
| 78 |
\draw [black,fill=black,line width=1pt] (0,0) -- (0,1) -- (1,1) -- cycle; |
| 79 |
}{} |
| 80 |
\ifthenelse{\equal{#3}{b}}{ |
| 81 |
\draw [black,fill=black,line width=1pt] (0,1) -- (1,1) -- (1,0) -- cycle; |
| 82 |
}{} |
| 83 |
\ifthenelse{\equal{#4}{b}}{ |
| 84 |
\draw [black,fill=black,line width=1pt] (1,1) -- (1,0) -- (0,0) -- cycle; |
| 85 |
}{} |
| 86 |
\ifthenelse{\equal{#5}{b}}{ |
| 87 |
\draw [black,fill=black,line width=1pt] (1,0) -- (0,0) -- (0,1) -- cycle; |
| 88 |
}{} |
| 89 |
\draw[black,line width=1pt] (0,0) rectangle (1,1); |
| 90 |
\end{scope} |
| 91 |
} |
| 92 |
|
| 93 |
\newcommand{\tileA}[1][(0,0)]{\diagonalsquare[#1]{x}{w}{x}{b}} |
| 94 |
\newcommand{\tileB}[1][(0,0)]{\diagonalsquare[#1]{b}{x}{w}{x}} |
| 95 |
\newcommand{\tileC}[1][(0,0)]{\diagonalsquare[#1]{x}{b}{x}{w}} |
| 96 |
\newcommand{\tileD}[1][(0,0)]{\diagonalsquare[#1]{w}{x}{b}{x}} |
| 97 |
|
| 98 |
\newcommand{\truchetsplithex}[1][(0,0)]{ |
| 99 |
\begin{scope}[shift={#1}] |
| 100 |
\draw[white,fill=white] (0,0) -- (1,0) -- (1.5,0.866) -- (1,1.732) -- (0,1.732) -- (-0.5,0.866) -- cycle; |
| 101 |
\draw[black,fill=black] (0,0) -- (.5,0) -- (.5,1.732) -- (0,1.732) -- (-0.5,0.866) -- cycle; |
| 102 |
\draw [black,fill=black,domain=120:240,line width=1pt] plot ({1.5+0.5*cos(\x)}, {0.866+0.5*sin(\x)}) -- (1.5,0.866) -- cycle; |
| 103 |
\draw [white,fill=white,domain=-60:60,line width=1pt] plot ({-0.5+0.5*cos(\x)}, {0.866+0.5*sin(\x)}) -- (-0.5,0.866) -- cycle; |
| 104 |
\draw[black,line width=1pt] (0,0) -- (1,0) -- (1.5,0.866) -- (1,1.732) -- (0,1.732) -- (-0.5,0.866) -- cycle; |
| 105 |
\end{scope} |
| 106 |
} |
| 107 |
|
| 108 |
\newcommand{\truchethex}[8][(0,0)]{ |
| 109 |
\begin{scope}[shift={#1}] |
| 110 |
\ifthenelse{\equal{#2}{b}}{ |
| 111 |
\draw[black,fill=black] (0,0) -- (1,0) -- (1.5,0.866) -- (1,1.732) -- (0,1.732) -- (-0.5,0.866) -- cycle; |
| 112 |
}{ |
| 113 |
\draw[white,fill=white] (0,0) -- (1,0) -- (1.5,0.866) -- (1,1.732) -- (0,1.732) -- (-0.5,0.866) -- cycle; |
| 114 |
} |
| 115 |
\ifthenelse{\equal{#3}{#2}}{}{ |
| 116 |
\ifthenelse{\equal{#3}{b}}{ |
| 117 |
\draw [black,fill=black,domain=240:360,line width=1pt] plot ({0.5*cos(\x)}, {1.732+0.5*sin(\x)}) -- (0,1.732) -- cycle; |
| 118 |
}{ |
| 119 |
\draw [white,fill=white,domain=240:360,line width=1pt] plot ({0.5*cos(\x)}, {1.732+0.5*sin(\x)}) -- (0,1.732) -- cycle; |
| 120 |
} |
| 121 |
} |
| 122 |
\ifthenelse{\equal{#4}{#2}}{}{ |
| 123 |
\ifthenelse{\equal{#4}{b}}{ |
| 124 |
\draw [black,fill=black,domain=180:300,line width=1pt] plot ({1+0.5*cos(\x)}, {1.732+0.5*sin(\x)}) -- (1,1.732) -- cycle; |
| 125 |
}{ |
| 126 |
\draw [white,fill=white,domain=180:300,line width=1pt] plot ({1+0.5*cos(\x)}, {1.732+0.5*sin(\x)}) -- (1,1.732) -- cycle; |
| 127 |
} |
| 128 |
} |
| 129 |
\ifthenelse{\equal{#5}{#2}}{}{ |
| 130 |
\ifthenelse{\equal{#5}{b}}{ |
| 131 |
\draw [black,fill=black,domain=120:240,line width=1pt] plot ({1.5+0.5*cos(\x)}, {0.866+0.5*sin(\x)}) -- (1.5,0.866) -- cycle; |
| 132 |
}{ |
| 133 |
\draw [white,fill=white,domain=120:240,line width=1pt] plot ({1.5+0.5*cos(\x)}, {0.866+0.5*sin(\x)}) -- (1.5,0.866) -- cycle; |
| 134 |
} |
| 135 |
} |
| 136 |
\ifthenelse{\equal{#6}{#2}}{}{ |
| 137 |
\ifthenelse{\equal{#6}{b}}{ |
| 138 |
\draw [black,fill=black,domain=60:180,line width=1pt] plot ({1+0.5*cos(\x)}, {0.5*sin(\x)}) -- (1,0) -- cycle; |
| 139 |
}{ |
| 140 |
\draw [white,fill=white,domain=60:180,line width=1pt] plot ({1+0.5*cos(\x)}, {0.5*sin(\x)}) -- (1,0) -- cycle; |
| 141 |
} |
| 142 |
} |
| 143 |
\ifthenelse{\equal{#7}{#2}}{}{ |
| 144 |
\ifthenelse{\equal{#7}{b}}{ |
| 145 |
\draw [black,fill=black,domain=0:120,line width=1pt] plot ({0.5*cos(\x)}, {0.5*sin(\x)}) -- (0,0) -- cycle; |
| 146 |
}{ |
| 147 |
\draw [white,fill=white,domain=0:120,line width=1pt] plot ({0.5*cos(\x)}, {0.5*sin(\x)}) -- (0,0) -- cycle; |
| 148 |
} |
| 149 |
} |
| 150 |
\ifthenelse{\equal{#8}{#2}}{}{ |
| 151 |
\ifthenelse{\equal{#8}{b}}{ |
| 152 |
\draw [black,fill=black,domain=-60:60,line width=1pt] plot ({-0.5+0.5*cos(\x)}, {0.866+0.5*sin(\x)}) -- (-0.5,0.866) -- cycle; |
| 153 |
}{ |
| 154 |
\draw [white,fill=white,domain=-60:60,line width=1pt] plot ({-0.5+0.5*cos(\x)}, {0.866+0.5*sin(\x)}) -- (-0.5,0.866) -- cycle; |
| 155 |
} |
| 156 |
} |
| 157 |
\draw[black,line width=1pt] (0,0) -- (1,0) -- (1.5,0.866) -- (1,1.732) -- (0,1.732) -- (-0.5,0.866) -- cycle; |
| 158 |
\end{scope} |
| 159 |
} |
| 160 |
|
| 161 |
\newenvironment{rotatehex}[1]{ |
| 162 |
\begin{scope}[shift={(0.5,0.866)}] |
| 163 |
\begin{scope}[rotate=#1] |
| 164 |
\begin{scope}[shift={(-0.5,-0.866)}] |
| 165 |
}{ |
| 166 |
\end{scope} |
| 167 |
\end{scope} |
| 168 |
\end{scope} |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
\newcommand{\truchetcube}[7][(0,0)]{ |
| 173 |
\begin{scope}[shift={#1}] |
| 174 |
%1.17,0.22 |
| 175 |
%-0.38,0.67 |
| 176 |
\coordinate (A) at (0,0); |
| 177 |
\coordinate (B) at (1.17,0.22); |
| 178 |
\coordinate (C) at (0.57,0.84); |
| 179 |
\coordinate (D) at (-0.6,0.62); |
| 180 |
\coordinate (E) at (0,1); |
| 181 |
\coordinate (F) at (1.17,1.22); |
| 182 |
\coordinate (G) at (0.57,1.84); |
| 183 |
\coordinate (H) at (-0.6,1.62); |
| 184 |
%faces |
| 185 |
\ifthenelse{\equal{#2}{b}} |
| 186 |
{\fill[fill=black,fill opacity=0.6] (A) -- (B) -- (C) -- (D) -- cycle;} |
| 187 |
{\fill[fill=white,fill opacity=0.6] (A) -- (B) -- (C) -- (D) -- cycle;} |
| 188 |
\ifthenelse{\equal{#3}{b}} |
| 189 |
{\fill[fill=black,fill opacity=0.6] (A) -- (B) -- (F) -- (E) -- cycle;} |
| 190 |
{\fill[fill=white,fill opacity=0.6] (A) -- (B) -- (F) -- (E) -- cycle;} |
| 191 |
\ifthenelse{\equal{#4}{b}} |
| 192 |
{\fill[fill=black,fill opacity=0.6] (B) -- (C) -- (G) -- (F) -- cycle;} |
| 193 |
{\fill[fill=white,fill opacity=0.6] (B) -- (C) -- (G) -- (F) -- cycle;} |
| 194 |
\ifthenelse{\equal{#5}{b}} |
| 195 |
{\fill[fill=black,fill opacity=0.6] (C) -- (D) -- (H) -- (G) -- cycle;} |
| 196 |
{\fill[fill=white,fill opacity=0.6] (C) -- (D) -- (H) -- (G) -- cycle;} |
| 197 |
\ifthenelse{\equal{#6}{b}} |
| 198 |
{\fill[fill=black,fill opacity=0.6] (D) -- (A) -- (E) -- (H) -- cycle;} |
| 199 |
{\fill[fill=white,fill opacity=0.6] (D) -- (A) -- (E) -- (H) -- cycle;} |
| 200 |
\ifthenelse{\equal{#7}{b}} |
| 201 |
{\fill[fill=black,fill opacity=0.6] (E) -- (F) -- (G) -- (H) -- cycle;} |
| 202 |
{\fill[fill=white,fill opacity=0.6] (E) -- (F) -- (G) -- (H) -- cycle;} |
| 203 |
%edges |
| 204 |
\draw[black,line width=1pt] (A) -- (B) -- (C) -- (D) -- cycle; |
| 205 |
\draw[black,line width=1pt] (E) -- (F) -- (G) -- (H) -- cycle; |
| 206 |
\draw[black,line width=1pt] (A) -- (E); |
| 207 |
\draw[black,line width=1pt] (B) -- (F); |
| 208 |
\draw[black,line width=1pt] (C) -- (G); |
| 209 |
\draw[black,line width=1pt] (D) -- (H); |
| 210 |
\end{scope} |
| 211 |
} |
| 212 |
|
| 213 |
\endinput |
| 214 |
%% |
| 215 |
%% End of file `tikz-truchet.sty'. |