-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
346 lines (321 loc) · 10.8 KB
/
index.html
File metadata and controls
346 lines (321 loc) · 10.8 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<!DOCTYPE html>
<html>
<head>
<title>Shaper Taper 🀺🁘🁊🁜 Generate repeatable Shaper Origin dominos</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(1.75in, 1fr));
grid-template-rows: repeat(auto-fit, auto);
/* grid-column-gap: 0.2in;
grid-row-gap: 2in; */
}
.domino {
page-break-inside: avoid;
}
body {
margin: 0;
}
nav {
background-color: rgb(10, 110, 204);
color: #eee;
}
.options {
display: flex;
flex-direction: row;
}
.options label {
flex: 1;
}
.options input[type="text"] {
width: 100px;
}
.print {
font-size: 2rem;
background-color: greenyellow;
border-radius: 10px;
border: solid 3px black;
cursor: pointer;
}
@media print {
nav {
display: none;
}
.print {
display: none;
}
}
h1 {
font-family: "Stardos Stencil";
font-weight: normal;
font-size: 0.5in;
}
h2 {
margin-top: 0;
}
</style>
</head>
<body>
<svg height="0" width="0" style="display: none;">
<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>
<p>
Print out a regular sheet of paper with Shaper Origin compatible
fudicial dominos on it. Default presets are optimal for a 8x11" US
letter.
</p>
<p>The dominoes generated will always match the Project Name.</p>
<div class="options">
<label>
<input type="text" v-model="randomSeed" placeholder="random seed" />
Project Name
</label>
<label>
<input type="number" v-model="dominoCount" min="1" max="373" />
Dominos
</label>
<label>
<input type="number" v-model="rowSpacing" min="1" size="1" />
Row Spacing
</label>
<label>
<input type="number" v-model="columnSpacing" min="1" size="1" />
Column Spacing
</label>
</div>
</nav>
<h1>
{{randomSeed}}
<button class="print" onClick="window.print()">Print</button>
</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"
:style="{ 'grid-column-gap': columnSpacing+'mm', 'grid-row-gap': rowSpacing+'mm'}"
>
<!-- <domino-template dots="permutation[d]"/> -->
<div v-for="d in permutation" 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: 28,
rowSpacing: 20,
columnSpacing: 1,
validCombos: validCombinations,
};
},
computed: {
permutation() {
let shuffledDominoes = [].concat(this.validCombos);
Math.seedrandom(this.randomSeed);
for (let i = this.validCombos.length - 1; i >= 0; i--) {
let select = Math.floor(Math.random() * i);
let swap = shuffledDominoes[i];
shuffledDominoes[i] = shuffledDominoes[select];
shuffledDominoes[select] = swap;
console.log;
}
console.log(shuffledDominoes[0][0]);
// shuffledDominoes.length = this.dominoCount;
return shuffledDominoes.slice(0, this.dominoCount);
},
},
});
</script>
</body>
</html>