-
Notifications
You must be signed in to change notification settings - Fork 0
/
dominoes.py
67 lines (66 loc) · 15.7 KB
/
dominoes.py
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
DWIDTH = 96
DHEIGHT = 192
M2d_IDENTITY = '1, 0, 0, 1, 0, 0'
M2d_ROTLEFT = '0, -1, 1, 0, 0, 106'
M2d_ROTRIGHT = '0, 1, -1, 0, 0, 202'
SVG_DICT = dict( (
((0, 0), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /></g></svg>'''),
((0, 1), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="48" cy="48" r="7" /></g></g></svg>'''),
((0, 2), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((0, 3), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((0, 4), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((0, 5), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((0, 6), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="47" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="47" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((1, 1), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="48" cy="48" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="48" cy="48" r="7" /></g></g></svg>'''),
((1, 2), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="48" cy="48" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((1, 3), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="48" cy="48" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((1, 4), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="48" cy="48" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((1, 5), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="48" cy="48" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((1, 6), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="48" cy="48" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="47" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="47" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((2, 2), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((2, 3), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((2, 4), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((2, 5), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((2, 6), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="47" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="47" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((3, 3), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((3, 4), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((3, 5), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((3, 6), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="47" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="47" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((4, 4), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((4, 5), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((4, 6), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="47" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="47" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((5, 5), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((5, 6), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="48" cy="48" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="47" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="47" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
((6, 6), '''<svg xmlns="http://www.w3.org/2000/svg">
<g transform="matrix({matrix})"><rect class="rect" height="192" width="96" x="5" y="5" /><line class="line" x1="11" x2="95" y1="101" y2="101" /><g transform="matrix(1, 0, 0, 1, 5, 5)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="47" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="47" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g><g transform="matrix(1, 0, 0, 1, 5, 101)"><circle class="pip" cx="78" cy="16" r="7" /><circle class="pip" cx="78" cy="47" r="7" /><circle class="pip" cx="78" cy="78" r="7" /><circle class="pip" cx="16" cy="16" r="7" /><circle class="pip" cx="16" cy="47" r="7" /><circle class="pip" cx="16" cy="78" r="7" /></g></g></svg>'''),
)
DOMINO_CSS = .rect { stroke: rgb(0,0,0); fill: rgb(255,255,255); stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; }
.line { stroke: rgb(0,0,0); stroke-width: 1px; }
.pip { stroke: rgb(0,0,0); fill: rgb(0,0,0); }