-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.html
482 lines (478 loc) · 14.8 KB
/
index.html
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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
<!DOCTYPE html>
<html lang="en" xml:lang="en" xmlns= "http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="google" content="notranslate">
<meta http-equiv="Content-Language" content="en">
<title>Twisty Polyhedra</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<style>
* {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
canvas {
cursor: pointer;
}
#solverloader {
display: inline-block;
border: 8px solid skyblue;
border-radius: 50%;
border-top: 8px solid white;
width: 12px;
height: 12px;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}
/* Safari */
@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.makemovebutton {
vertical-align: top;
font-size: 30px;
font-weight: bold;
padding: 10px;
cursor: pointer;
}
</style>
</head>
<body
style="
background-color: #202020;
color: white;
text-align: center;
min-width: 1024px;
min-height: 737px;
"
>
<span
style="
display: inline-block;
position: fixed;
bottom: 10px;
left: 10px;
font-size: 40px;
"
>
<a
href="https://github.com/aditya-r-m/twisty-polyhedra"
target="_blank"
style="color: skyblue; text-decoration: none"
>
</>
</a>
</span>
<div
id="success"
style="
display: none;
vertical-align: top;
width: 394px;
margin-top: 100px;
border: 3px solid skyblue;
border-radius: 20px;
"
>
<h2 style="position: relative; font-family: cursive">
Congratulations!
<div
onclick="menu.style.display='inline-block';success.style.display='none'"
style="
font-family: fantasy;
cursor: pointer;
position: absolute;
top: 0px;
right: 20px;
color: red;
"
>
X
</div>
</h2>
<p id="message"></p>
</div>
<div
id="help"
style="
display: none;
vertical-align: top;
width: 394px;
margin-top: 50px;
border: 3px solid skyblue;
border-radius: 20px;
"
>
<h2 style="font-family: cursive; position: relative">
HELP
<div
onclick="menu.style.display='inline-block';help.style.display='none'"
style="
font-family: fantasy;
cursor: pointer;
position: absolute;
top: 0;
right: 20px;
color: red;
"
>
X
</div>
</h2>
<ul style="margin-right: 10px">
<li style="text-align: left; margin-bottom: 10px">
To twist a slice,
<br />press (left-mouse-button OR touch-screen) over a sticker &
drag.
</li>
<li style="text-align: left; margin-bottom: 10px">
To rotate the puzzle,
<br />press (left-mouse-button OR touch-screen) on the empty-space
near the puzzle & drag. <br /><br />Alternatively (on PC),
<br />press (right-bouse-button OR ctrl+left-mouse-button) anywhere on
puzzle canvas & drag.
</li>
<li style="text-align: left; margin-bottom: 10px">
Click on any puzzle in the menu to select it & Trigger automatic
scramble using the play button.
</li>
<li style="text-align: left; margin-bottom: 10px">
You can use the solve button to auto-generate solutions for differnt
puzzles to learn from.
</li>
<li style="text-align: left; margin-bottom: 10px">
Before a given puzzle state can be solved by the algorithm,
preprocessing must be done for the shape & size. The preprocessed
data stays in memory till the tab is killed, so subsequent solves are
much faster than the first one.
</li>
<li style="text-align: left; margin-bottom: 10px">
The interface has an advanced feature to point & swap stickers.
This can be helpful to analyze different positions & how the
solver tackles them. Note that it is very easy to bring the puzzle to
unsolvable states by using this feature. The automated solver will do
best effort fixing of such states.
</li>
</ul>
<h2 style="font-family: cursive">Happy Solving!</h2>
</div>
<div
id="menu"
style="
display: inline-block;
vertical-align: top;
text-align: center;
margin-top: 50px;
width: 400px;
"
>
<div id="puzzlemenu" style="display: inline-block; height: 300px">
<div id="shapemenu" style="display: inline-block; height: 300px">
<div style="height: 100px">
<div style="display: inline-block; width: 100px; height: 100px">
<canvas id="tetrahedron" width="100px" height="100px"></canvas>
</div>
</div>
<div style="height: 100px">
<div
style="
display: inline-block;
width: 100px;
height: 100px;
margin-right: 80px;
"
>
<canvas id="cube" width="100px" height="100px"></canvas>
</div>
<div style="display: inline-block; width: 100px; height: 100px">
<canvas id="octahedron" width="100px" height="100px"></canvas>
</div>
</div>
<div style="height: 100px">
<div
style="
display: inline-block;
width: 100px;
height: 100px;
margin-right: 20px;
margin-top: 15px;
"
>
<canvas id="dodecahedron" width="100px" height="100px"></canvas>
</div>
<div style="display: inline-block; width: 100px; height: 100px">
<canvas id="icosahedron" width="100px" height="100px"></canvas>
</div>
</div>
</div>
<div id="sizemenu" style="height: 300px; margin-top: 15px">
<div
style="
display: inline-block;
vertical-align: top;
margin-top: 100px;
"
>
<div style="width: 100px; height: 100px">
<canvas id="size-1" width="100px" height="100px"></canvas>
</div>
</div>
<div style="vertical-align: top">
<div style="display: inline-block; width: 100px; height: 100px">
<canvas id="size-2" width="100px" height="100px"></canvas>
</div>
<div style="display: inline-block; width: 100px; height: 100px">
<canvas id="size-3" width="100px" height="100px"></canvas>
</div>
</div>
</div>
</div>
<div
id="configurationmenu"
style="
vertical-align: top;
text-align: left;
height: 300px;
margin-top: 19px;
display: none;
"
>
<div
style="
border: 3px solid white;
padding: 40px;
margin-top: 100px;
border-radius: 10%;
"
>
<input
autocomplete="off"
checked
type="checkbox"
value="exp"
id="exstick"
name="exstick"
onclick="window.explodedStickers=!window.explodedStickers"
/>
<label for="exstick">Explode Stickers</label>
<br />
<input
autocomplete="off"
type="checkbox"
value="stat"
id="statconfig"
name="statconfig"
onclick="stats.style.display=(stats.style.display === 'none' ? 'inline' : 'none')"
/>
<label for="statconfig">Show Stats</label>
<br />
<input
autocomplete="off"
type="checkbox"
value="rearv"
id="rearvconf"
name="rearvconf"
onclick="window.showRearView=!window.showRearView; rearView.style.display=(window.showRearView ? 'inline-block' : 'none')"
/>
<label for="rearvconf">Show Rear View</label>
<br />
<input
autocomplete="off"
type="checkbox"
value="anim"
id="anim"
name="anim"
onclick="window.animate=!window.animate;"
/>
<label for="anim">Disable twist animations</label>
<br />
<input
autocomplete="off"
type="checkbox"
value="pns"
id="pns"
name="pns"
onclick="window.pointAndSwap=!window.pointAndSwap; window.tempS = undefined;"
/>
<label for="pns">Point & Swap mode</label>
<br />
<input
type="button"
value="-"
onclick="updateSizeOffset(document.getElementById('soff'), -1)"
/>
<input
autocomplete="off"
type="textbox"
value="0"
id="soff"
name="soff"
size="1"
onblur="updateSizeOffset(this, 0)"
/>
<input
type="button"
value="+"
onclick="updateSizeOffset(document.getElementById('soff'), 1)"
/>
<label>Size Offset</label>
</div>
</div>
<div style="margin: 50px 65px; height: 35px; font-size: 40px">
<span
onclick="help.style.display='inline-block';menu.style.display='none'"
style="
cursor: pointer;
float: left;
width: 50px;
height: 50px;
line-height: 50px;
color: skyblue;
"
>?</span
>
<span
id="settingsmenubutton"
onclick="puzzlemenu.style.display=settingsmenubutton.style.display='none';configurationmenu.style.display=puzzlemenubutton.style.display='inline-block';"
style="cursor: pointer; width: 50px; height: 50px; line-height: 50px"
>⚙</span
>
<span
id="puzzlemenubutton"
onclick="showShapeMenu();"
style="
cursor: pointer;
width: 50px;
height: 50px;
line-height: 50px;
display: none;
color: red;
"
>◁</span
>
<span
id="startbutton"
onclick="selectedPuzzle.scramble();"
style="
cursor: pointer;
float: right;
width: 50px;
height: 50px;
line-height: 42px;
color: lawngreen;
font-size: 60px;
"
>►</span
>
</div>
<div id="solverunsupported" style="color: skyblue; display: none">
Solver could not be initialized. Please ensure that your browser
supports background workers and you are accessing the application
through a remote or local server.
</div>
<div id="solvewrapper">
<div
id="solvebutton"
onclick="generateSolution();"
style="
display: inline-block;
cursor: pointer;
color: skyblue;
padding: 3px;
border: 3px solid skyblue;
border-radius: 10px;
margin-bottom: 25px;
"
>
𝓢𝓸𝓵𝓿𝓮
</div>
<div
id="solverstatus"
style="display: none; cursor: pointer; color: skyblue"
>
<div id="solverstatustext" style="padding-bottom: 10px"></div>
<span id="solverloader"></span>
</div>
</div>
</div>
<div style="display: inline-block; color: skyblue">
<canvas id="gameCanvas" width="600px" height="600px"></canvas>
<div id="solutionpanel" width="600px" style="display: none">
<span id="revertsolutionpanel">
<span class="makemovebutton" onclick="revertAllSolverMoves()"
>|<</span
>
<span class="makemovebutton" onclick="revertSolverMoveSequence()"
><<</span
>
<span class="makemovebutton" onclick="revertSolverMove()"><</span>
</span>
<span
id="solutioninfo"
style="display: inline-block; width: 150px"
></span>
<span id="applysolutionpanel">
<span class="makemovebutton" onclick="makeSolverMove()">></span>
<span class="makemovebutton" onclick="makeSolverMoveSequence()"
>>></span
>
<span class="makemovebutton" onclick="makeAllSolverMoves()">>|</span>
</span>
</div>
<span
id="stats"
style="position: fixed; right: 50px; top: 50px; display: none"
>Time Taken: --:--, Moves Made: --</span
>
</div>
<div
id="rearView"
style="position: fixed; display: none; right: 0px; bottom: 20px"
>
<canvas id="gameCanvasInverted" width="200px" height="200px"></canvas>
</div>
<script type="text/javascript" src="src/utils.js"></script>
<script type="text/javascript" src="src/classes/Vector.js"></script>
<script type="text/javascript" src="src/classes/Quaternion.js"></script>
<script type="text/javascript" src="src/classes/Point.js"></script>
<script type="text/javascript" src="src/classes/Sticker.js"></script>
<script type="text/javascript" src="src/classes/Face.js"></script>
<script type="text/javascript" src="src/classes/Cycle.js"></script>
<script type="text/javascript" src="src/classes/Puzzle.js"></script>
<script type="text/javascript" src="src/classes/Puzzles/Cube.js"></script>
<script
type="text/javascript"
src="src/classes/Puzzles/Tetrahedron.js"
></script>
<script
type="text/javascript"
src="src/classes/Puzzles/Octahedron.js"
></script>
<script
type="text/javascript"
src="src/classes/Puzzles/Dodecahedron.js"
></script>
<script
type="text/javascript"
src="src/classes/Puzzles/Icosahedron.js"
></script>
<script type="text/javascript" src="src/solver.js"></script>
<script type="text/javascript" src="src/menu.js"></script>
<script type="text/javascript" src="src/game.js"></script>
</body>
</html>