-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
205 lines (177 loc) · 7.47 KB
/
index.html
File metadata and controls
205 lines (177 loc) · 7.47 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<!doctype html>
<html>
<head>
<title>Shaper Tape Generator</title>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/seedrandom/2.4.3/seedrandom.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Stardos+Stencil" rel="stylesheet">
<style>
.domino-grid{
display:grid;
grid-template-columns: repeat(auto-fit, minmax(2in, 1fr));
grid-template-rows: repeat(auto-fit, auto);
grid-column-gap: 0.2in;
grid-row-gap: 2in;
}
.domino{
page-break-inside: avoid;
}
nav{
background-color:#333;
color:#eee;
}
h1{
font-family: 'Stardos Stencil';
font-weight:normal;
font-size: 0.5in;
}
</style>
</head>
<body>
<svg height="0" width="0">
<defs>
<rect id="domino_body" width="1.6666in" height="0.5in" rx="0.1in" style="fill:black; stroke-size:0.01in; stroke:black;"/>
<circle id="domino_dot" cx="0" cy="0" r="0.05in" style="fill:white"/>
</defs>
</svg>
<div id="app">
<nav>
<h2>Shaper Taper</h2>
<input type="text" v-model="randomSeed" placeholder="random seed">
<input type="number" v-model="dominoCount" min="1" max="373">
<input type="number" v-model="rowSpacing" min="1">
<input type="submit" value="Print">
</nav>
<h1>{{randomSeed}}</h1>
<!-- <svg style="margin-left:-20px; height:70px">
<path d="M 28.346456692913392 66.89763779527559A9.448818897637796,9.448818897637796 0 0,1 18.8976377952756,57.44881889763779L 18.8976377952756 28.34645669291339A9.448818897637796,9.448818897637796 0 0,1 28.346456692913392,18.897637795275593L 171.9685039370079 18.897637795275593A9.448818897637796,9.448818897637796 0 0,1 181.4173228346457,28.34645669291339L 181.4173228346457 57.44881889763779A9.448818897637796,9.448818897637796 0 0,1 171.9685039370079,66.89763779527559z" fill="black" stroke="none" /><circle cx="34.015748031496074" cy="52.34645669291339" fill="white" r="4.724409448818898" /><circle cx="34.015748031496074" cy="33.44881889763779" fill="white" r="4.724409448818898" /><circle cx="52.91338582677167" cy="52.34645669291339" fill="white" r="4.724409448818898" /><circle cx="71.81102362204726" cy="33.44881889763779" fill="white" r="4.724409448818898" /><circle cx="90.70866141732286" cy="52.34645669291339" fill="white" r="4.724409448818898" /><circle cx="90.70866141732286" cy="33.44881889763779" fill="white" r="4.724409448818898" /><circle cx="109.60629921259844" cy="52.34645669291339" fill="white" r="4.724409448818898" /><circle cx="109.60629921259844" cy="33.44881889763779" fill="white" r="4.724409448818898" /><circle cx="166.29921259842524" cy="52.34645669291339" fill="white" r="4.724409448818898" /><circle cx="166.29921259842524" cy="33.44881889763779" fill="white" r="4.724409448818898" />
</svg> -->
<div class="domino-grid">
<!-- <domino-template dots="permutation[d]"/> -->
<div v-for="d in permutation" :key="d" class="domino">
<svg width="2.02in" height="0.5in">
<use xlink:href="#domino_body" x="0.01in"/>
<!-- dots that never go away -->
<use xlink:href="#domino_dot" x="0.14in" y="0.16in"/>
<use xlink:href="#domino_dot" x="0.14in" y="0.35in"/>
<use xlink:href="#domino_dot" x="1.51in" y="0.16in"/>
<use xlink:href="#domino_dot" x="1.51in" y="0.35in"/>
<!-- row 1 (left to right) -->
<use xlink:href="#domino_dot" x="0.335714in" y="0.16in" v-if="d[0][0]"/>
<use xlink:href="#domino_dot" x="0.531428in" y="0.16in" v-if="d[0][1]"/>
<use xlink:href="#domino_dot" x="0.727143in" y="0.16in" v-if="d[0][2]"/>
<use xlink:href="#domino_dot" x="0.922857in" y="0.16in" v-if="d[0][3]"/>
<use xlink:href="#domino_dot" x="1.118571in" y="0.16in" v-if="d[0][4]"/>
<use xlink:href="#domino_dot" x="1.314286in" y="0.16in" v-if="d[0][5]"/>
<!-- row 2 (right to left) -->
<use xlink:href="#domino_dot" x="1.314286in" y="0.35in" v-if="d[1][0]" />
<use xlink:href="#domino_dot" x="1.118571in" y="0.35in" v-if="d[1][1]"/>
<use xlink:href="#domino_dot" x="0.922857in" y="0.35in" v-if="d[1][2]"/>
<use xlink:href="#domino_dot" x="0.7237143in" y="0.35in" v-if="d[1][3]"/>
<use xlink:href="#domino_dot" x="0.5341428in" y="0.35in" v-if="d[1][4]"/>
<use xlink:href="#domino_dot" x="0.3345714in" y="0.35in" v-if="d[1][5]"/>
<!-- left to right version for visual debugging -->
<!-- <use xlink:href="#domino_dot" x="0.3345714in" y="0.35in" v-if="d[1][0]"/>
<use xlink:href="#domino_dot" x="0.5341428in" y="0.35in" v-if="d[1][1]"/>
<use xlink:href="#domino_dot" x="0.7237143in" y="0.35in" v-if="d[1][2]"/>
<use xlink:href="#domino_dot" x="0.922857in" y="0.35in" v-if="d[1][3]"/>
<use xlink:href="#domino_dot" x="1.118571in" y="0.35in" v-if="d[1][4]"/>
<use xlink:href="#domino_dot" x="1.314286in" y="0.35in" v-if="d[1][5]"/> -->
</svg>
</div>
</div>
</div>
<script>
const validBitCombos = [
[ //0 one/five bit
[0,0,0,0,0,1],
[0,0,0,0,1,0],
[0,0,0,1,0,0],
[0,0,1,0,0,0],
[0,1,0,0,0,0],
[1,0,0,0,0,0],
],
[ //1 two/four bit
[0,0,0,0,1,1],
[0,0,0,1,1,0],
[0,0,1,1,0,0],
[0,1,1,0,0,0],
[1,1,0,0,0,0],
[0,0,0,1,0,1],
[0,0,1,0,1,0],
[0,1,0,1,0,0],
[1,0,1,0,0,0],
[0,0,1,0,0,1],
[0,1,0,0,1,0],
[1,0,0,1,0,0],
[0,1,0,0,0,1],
[1,0,0,0,1,0],
[1,0,0,0,0,1],
],
[ //2 three bit
[0,0,0,1,1,1],
[0,0,1,1,1,0],
[0,1,1,1,0,0],
[1,1,1,0,0,0],
[0,0,1,0,1,1],
[0,1,0,1,1,0],
[1,0,1,1,0,0],
[0,0,1,1,0,1],
[0,1,1,0,1,0],
[1,1,0,1,0,0],
[0,1,0,1,0,1],
[1,0,1,0,1,0],
]]
let validCombinations = [
[[0,0,0,0,0,0],[1,1,1,1,1,1]]
];
function invert(arr){
newarr = []
for(let i=0; i<arr.length; i++){
newarr.push( (arr[i] === 1) ? 0 : 1 )
}
return newarr
}
// match each subset of valid bit combos with every inverted combination
// 1 with inverted 5
// 2 with inverted 4
// 3 with itself without repeating
for(let subset=0; subset<validBitCombos.length; subset++) {
for(let topRow=0; topRow<validBitCombos[subset].length; topRow++){
for(let botRow=0; botRow<validBitCombos[subset].length; botRow++){
if(topRow !== botRow) {
validCombinations.push( [validBitCombos[subset][topRow], invert(validBitCombos[subset][botRow])] )
}
}
}
}
// console.log(validCombinations)
const app = new Vue({
el: '#app',
components: {'domino-template': {template: "#domino-template"} },
data() {
return {
randomSeed: 'My Rad Project',
dominoCount: 25,
rowSpacing: 20
}
},
computed: {
permutation() {
let shuffledDominoes = validCombinations
Math.seedrandom(this.randomSeed)
for(let i=shuffledDominoes.length - 1; i>=0; i--){
let select = Math.floor(Math.random() * i)
let swap = shuffledDominoes[select]
shuffledDominoes[select] = shuffledDominoes[i]
shuffledDominoes[i] = swap
}
// shuffledDominoes.length = this.dominoCount
return shuffledDominoes
}
}
})
</script>
</body>
</html>