-
Notifications
You must be signed in to change notification settings - Fork 0
/
tilings.sty
80 lines (71 loc) · 2.25 KB
/
tilings.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
\ProvidesPackage{tilings}
\RequirePackage{tikz}
\RequirePackage{xifthen}
\usetikzlibrary{calc}
\definecolor{obstructionred}{RGB}{153,0,0}
\definecolor{requirementgreen}{RGB}{0,153,0}
% #1: scale
% Number
% #2: width
% Integer
% #3: height
% Integer
% #4: points
% Coordinate list on the form {x0/y0,...,xn/yn}
% #5: obstructions
% List of obstructions of the form {length/{(x0,y0),...,(xn/yn)}}
% #6: requirements
% List of requirements of the form {length/{(x0,y0),...,(xn/yn)}}
\newcommand{\tiling}[6]{%
\scalebox{#1}{%
\begin{tikzpicture}[
baseline = (current bounding box.center),
obpoint/.style = {circle, fill, obstructionred},
obedge/.style = {thick, obstructionred},
reqpoint/.style = {circle, fill, requirementgreen},
reqedge/.style = {thick, requirementgreen},
nonnode/.style = {inner sep=0.0pt, outer sep=0.0pt}]
\useasboundingbox (0.0,-.3) rectangle (#2,#3+.3);
\ifthenelse{#2>1 \OR #3>1}{%
\draw (0.01,0.01) grid (#2-0.01,#3-0.01);
}{}
\draw[rounded corners=5pt] (0.01,0.01) rectangle (#2-0.01,#3-0.01);
\foreach \x/\y in {#4}
{%
\filldraw (\x + .5, \y + .5) circle (2.5pt);
}
% Obstructions
\foreach [count=\obnum] \oblen/\obpoints in {#5}{%
\foreach [count=\i] \pt in \obpoints{%
\node[nonnode] (p\obnum o\i) at \pt {};
}
\foreach \i in {1,...,\oblen}{%
\filldraw[obpoint] (p\obnum o\i) circle (1.5pt);
}
\ifthenelse{\oblen>1}
{%
\draw[obedge] \foreach \x [remember=\x as \lastx (initially 1)] in {2,...,\oblen}{%
(p\obnum o\lastx) -- (p\obnum o\x)
};
}
{}
}
% Requirements
\foreach [count=\reqnum] \reqlen/\reqpoints in {#6}{%
\foreach [count=\i] \pt in \reqpoints{%
\node[nonnode] (p\reqnum r\i) at \pt {};
}
\foreach \i in {1,...,\reqlen}{%
\filldraw[reqpoint] (p\reqnum r\i) circle (1.5pt);
}
\ifthenelse{\reqlen>1}
{%
\draw[reqedge] \foreach \x [remember=\x as \lastx (initially 1)] in {2,...,\reqlen}{
(p\reqnum r\lastx) -- (p\reqnum r\x)
};
}
{}
}
\end{tikzpicture}
}
}