-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
722 lines (688 loc) · 30.9 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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>superkopf, the logical puzzle game</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="Superkopf is a logical puzzle game inspired by classic board games.">
<meta name="author" content="Frank R Thomsen">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="./img/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="96x96" href="./img/favicon-96x96.png">
<meta name="msapplication-TileColor" content="#eee">
<meta name="msapplication-TileImage" content="./img/ms-icon-144x144.png">
<meta name="theme-color" content="#eee">
<!----------------->
<!-- Main styles -->
<!----------------->
<style>
:root {
--color1: #BF3078;
--color2: #BF7830;
--color3: #BFBF30;
--color4: #30BF78;
--color5: #3078BF;
--color6: #7830BF;
--fg: #333;
--bg2: #ccc;
--bg1: #eee;
--bg: #fff;
}
body {
margin: 0;
padding: 0;
font: 1em/1.2 sans-serif;
color: var(--fg);
background-color: var(--bg1);
}
header,
main {
width: 100%;
max-width: 15rem;
margin: 0 auto;
text-align: center;
}
#welcome,
#game {
display: none;
}
#welcome:target,
#game:target {
display: block;
}
#welcome {
text-align: center;
}
.btn {
border: solid 1px var(--bg2);
color: var(--fg);
box-shadow: 0 .125rem .5rem hsla(0,0%,0%,.1);
background-color: transparent;
padding: .75rem 1rem;
border-radius: .5rem;
font-size: .8rem;
text-transform: uppercase;
font-weight: bold;
}
.title {
margin: 1rem 0 2rem;
font-size: 2.5rem;
border-bottom: solid 1px var(--bg2);
padding: 0 0 1rem;
font-weight: bold;
letter-spacing: -.5px;
display: inline-block;
}
.codes {
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
padding: 0 0 1rem;
}
</style>
</head>
<body>
<header>
<h1 class="title">superkopf</h1>
</header>
<!--------------->
<!-- Main HTML -->
<!--------------->
<main id="app">
<!-- Welcome screen -->
<section id="welcome">
<img src="img/logo.svg" alt="" style="width: 4rem; height: auto; margin: 0;">
<p>A puzzle game.<br>Try to guess the color sequence.</p>
<button class="btn" onclick="startGame()">Start game</button>
</section>
<!-- Game screen -->
<section id="game">
<div class="codes">
<hint-track></hint-track>
<code-track></code-track>
</div>
<code-input></code-input>
</section>
<!-- Game end dialog -->
<game-over></game-over>
</main>
<!-------------------------->
<!-- Code track Component -->
<!-------------------------->
<template id="codetrack">
<style>
ol {
margin: 0;
padding: 0;
list-style: none;
}
li {
color: #000;
font-weight: bold;
display: flex;
flex-flow: row nowrap;
align-items: center;
}
.code-item {
display: flex;
flex-flow: row nowrap;
align-items: center;
justify-content: center;
border-radius: 50%;
width: 2rem;
height: 2rem;
color: #fff;
margin: .25rem .125rem;
}
.code-color-1 {
background-color: var(--color1);
}
.code-color-2 {
background-color: var(--color2);
}
.code-color-3 {
background-color: var(--color3);
}
.code-color-4 {
background-color: var(--color4);
}
.code-color-5 {
background-color: var(--color5);
}
.code-color-6 {
background-color: var(--color6);
}
</style>
<ol id="codetracklist"></ol>
</template>
<script>
class CodeTrack extends HTMLElement {
// Define which custom element attributes to observe
static get observedAttributes() {
return ['guess-list']
}
// Create element and its shadow DOM
constructor() {
super()
let template = document.getElementById('codetrack'),
templateContent = template.content
const shadow = this.attachShadow({mode: 'open'}).appendChild(templateContent.cloneNode(true))
}
attributeChangedCallback(name, oldValue, newValue) {
const new_code = JSON.parse(newValue).pop()
if (new_code) {
const list_el = this.shadowRoot.getElementById('codetracklist')
let list_item = '<li>'
for (let c of new_code) {
list_item += `<span class="code-item code-color-${ c }">${ c }</span>`
}
list_item += '</li>'
list_el.innerHTML += list_item
} else {
this.shadowRoot.getElementById('codetracklist').innerHTML = ''
}
}
}
customElements.define('code-track', CodeTrack)
</script>
<!-------------------------->
<!-- Hint track Component -->
<!-------------------------->
<template id="hinttrack">
<style>
ol {
background-color: var(--bg1);
margin: 0;
padding: 0;
}
li {
display: flex;
flex-flow: row wrap;
height: 2.5rem;
align-items: center;
}
.white,
.black {
display: block;
text-indent: -1000rem;
flex: 0 0 auto;
height: .5rem;
width: .5rem;
border-radius: 50%;
border: solid 1px black;
background-color: black;
}
.white {
background-color: white;
}
</style>
<ol id="hinttracklist"></ol>
</template>
<script>
class HintTrack extends HTMLElement {
// Define which custom element attributes to observe
static get observedAttributes() {
return ['hint-list']
}
// Create element and its shadow DOM
constructor() {
super()
let template = document.getElementById('hinttrack'),
templateContent = template.content
const shadow = this.attachShadow({mode: 'open'}).appendChild(templateContent.cloneNode(true))
}
attributeChangedCallback(name, oldValue, newValue) {
const new_hints = JSON.parse(newValue).pop()
if (new_hints) {
const list_el = this.shadowRoot.getElementById('hinttracklist')
let list_item = '<li>'
for (let h of new_hints) {
if (h === 'black') {
list_item += '<span class="black">Correct color and position</span>'
} else if (h === 'white') {
list_item += '<span class="white">Correct color but not position</span>'
}
}
list_item += '</li>'
list_el.innerHTML += list_item
} else {
this.shadowRoot.getElementById('hinttracklist').innerHTML = ''
}
}
}
customElements.define('hint-track', HintTrack)
</script>
<!-------------------------->
<!-- Code input component -->
<!-------------------------->
<template id="codeinput">
<style>
form {
width: 100%;
}
input[type="submit"] {
border: solid 1px var(--bg2);
color: var(--fg);
box-shadow: 0 .125rem .5rem hsla(0,0%,0%,.1);
background-color: transparent;
padding: .75rem 1rem;
border-radius: .5rem;
font-size: .8rem;
text-transform: uppercase;
font-weight: bold;
margin: 1rem 0;
}
</style>
<form id="codeinputform">
<p>Make a seqence</p>
<color-picker></color-picker>
<color-picker></color-picker>
<color-picker></color-picker>
<color-picker></color-picker>
<input class="btn" type="submit" value="Guess">
</form>
</template>
<script>
class CodeInput extends HTMLElement {
// Create element and its shadow DOM
constructor() {
super()
let template = document.getElementById('codeinput')
let templateContent = template.content
const shadow = this.attachShadow({mode: 'open'}).appendChild(templateContent.cloneNode(true))
}
connectedCallback() {
const color_pickers = this.shadowRoot.querySelectorAll('color-picker')
// add event listener for form submit
this.shadowRoot.querySelector('#codeinputform').addEventListener("submit", function(ev) {
ev.preventDefault()
const guess = [
Number(this.children[1].getAttribute('color-pick')),
Number(this.children[2].getAttribute('color-pick')),
Number(this.children[3].getAttribute('color-pick')),
Number(this.children[4].getAttribute('color-pick'))
]
// send 'guess' event
this.dispatchEvent(new CustomEvent('guess', { bubbles: true, composed: true, detail: guess }))
// reset values after guess
color_pickers.forEach(function(picker) {
picker.setAttribute('color-pick', '')
})
})
color_pickers.forEach(function(picker) {
picker.addEventListener('colorpick', function(ev) {
ev.target.setAttribute('color-pick', ev.detail)
})
})
}
}
customElements.define('code-input', CodeInput)
</script>
<!------------------------->
<!-- Game over component -->
<!------------------------->
<template id="gameresult">
<style>
#gamewin,
#gameloose {
display: none;
position: fixed;
top: 3rem;
left: 50vw;
width: 16rem;
height: auto;
margin: 0 0 0 -8rem;
background-color: var(--bg1);
border: solid 1px var(--bg1);
border-radius: .5rem;
padding: 1rem 2rem 2rem;
box-shadow: 0 .5rem 1.5rem hsla(0,0%,0%,.5);
box-sizing: border-box;
z-index: 1000000;
}
.btn {
border: solid 1px var(--bg2);
color: var(--fg);
box-shadow: 0 .125rem .5rem hsla(0,0%,0%,.1);
background-color: transparent;
padding: .75rem 1rem;
border-radius: .5rem;
font-size: .8rem;
text-transform: uppercase;
font-weight: bold;
}
.guess-seq {
display: flex;
flex-flow: row nowrap;
align-items: center;
justify-content: center;
margin: 0;
}
.pick {
height: 2rem;
width: 2rem;
border-radius: 50%;
border: none;
padding: 0;
margin: .125rem;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
flex: 0 0 auto;
}
.pick-1,
.pick-2,
.pick-3,
.pick-4,
.pick-5,
.pick-6 {
color: var(--bg);
}
.pick-1 {
background-color: var(--color1);
}
.pick-2 {
background-color: var(--color2);
}
.pick-3 {
background-color: var(--color3);
}
.pick-4 {
background-color: var(--color4);
}
.pick-5 {
background-color: var(--color5);
}
.pick-6 {
background-color: var(--color6);
}
</style>
<div id="gamewin">
<h1 class="result-header">You win</h1>
<figure class="guess-seq"></figure>
<p>You cracked the code in <span class="guess-num"></span> attempts.</p>
<p><em>Praises will be sung about your victory.</em></p>
<button class="btn" onclick="startGame()">Try again?</button>
</div>
<div id="gameloose">
<h1 class="result-header">Unfortunately, you are terrible at this</h1>
<p>You have had 12 attempts at cracking the master code but still you fail.</p>
<p><em>Shame on you.</em></p>
<button class="btn" onclick="startGame()">Try again?</button>
</div>
</template>
<script>
class GameOver extends HTMLElement {
// Define which custom element attributes to observe
static get observedAttributes() {
return ['game-result']
}
// Create element and its shadow DOM
constructor() {
super()
let template = document.getElementById('gameresult')
let templateContent = template.content
const shadow = this.attachShadow({mode: 'open'}).appendChild(templateContent.cloneNode(true))
}
attributeChangedCallback(name, oldValue, newValue) {
let win_el = this.shadowRoot.querySelector('#gamewin'),
loose_el = this.shadowRoot.querySelector('#gameloose')
if (newValue) {
let result = JSON.parse(newValue)
if (result.win === true) {
loose_el.style.display = 'none'
win_el.style.display = 'block'
win_el.querySelector('.guess-num').innerHTML = result.guesses
win_el.querySelector('.guess-seq').innerHTML = `
<span class="pick pick-${result.last_guess[0]}">${result.last_guess[0]}</span>
<span class="pick pick-${result.last_guess[1]}">${result.last_guess[1]}</span>
<span class="pick pick-${result.last_guess[2]}">${result.last_guess[2]}</span>
<span class="pick pick-${result.last_guess[3]}">${result.last_guess[3]}</span>
`
confetti.start()
} else if (result.win === false) {
loose_el.style.display = 'block'
win_el.style.display = 'none'
} else {
loose_el.style.display = 'none'
win_el.style.display = 'none'
}
}
}
}
customElements.define('game-over', GameOver)
</script>
<!---------------------------->
<!-- Color picker Component -->
<!---------------------------->
<template id="colorpicker">
<style>
.picklist-wrapper {
position: relative;
display: inline-block;
}
#picklist {
list-style: none;
display: none;
position: absolute;
border: solid 1px var(--bg2);
top: 50%;
left: 50%;
width: 10.5rem;
height: 7.5rem;
margin: -4.75rem 0 0 -5.25rem;
background-color: var(--bg);
z-index: 999;
border-radius: .5rem;
box-shadow: 0 .125rem .5rem hsla(0,0%,0%,.1);
padding: .5rem;
}
#picklist.show {
display: flex;
flex-flow: row wrap;
align-items: center;
}
.pick-current {
height: 3rem;
width: 3rem;
border: solid 1px #000;
border-radius: 50%;
background-color: transparent;
}
.pick-option {
height: 3rem;
width: 3rem;
border-radius: 50%;
border: none;
padding: 0;
margin: .25rem;
}
.pick-1,
.pick-2,
.pick-3,
.pick-4,
.pick-5,
.pick-6 {
border: none;
color: var(--bg);
}
.pick-1 {
background-color: var(--color1);
}
.pick-2 {
background-color: var(--color2);
}
.pick-3 {
background-color: var(--color3);
}
.pick-4 {
background-color: var(--color4);
}
.pick-5 {
background-color: var(--color5);
}
.pick-6 {
background-color: var(--color6);
}
</style>
<div class="picklist-wrapper">
<button class="pick-current">0</button>
<ul id="picklist">
<li><button class="pick-option pick-1">1</button></li>
<li><button class="pick-option pick-2">2</button></li>
<li><button class="pick-option pick-3">3</button></li>
<li><button class="pick-option pick-4">4</button></li>
<li><button class="pick-option pick-5">5</button></li>
<li><button class="pick-option pick-6">6</button></li>
</ul>
</div>
</template>
<script>
class ColorPicker extends HTMLElement {
// Define which custom element attributes to observe
static get observedAttributes() {
return ['color-pick']
}
// Create element and its shadow DOM
constructor() {
super()
let template = document.getElementById('colorpicker'),
templateContent = template.content
const shadow = this.attachShadow({mode: 'open'}).appendChild(templateContent.cloneNode(true))
}
connectedCallback() {
const root = this.shadowRoot,
current_el = root.querySelector('.pick-current'),
picklist_el = root.querySelector('#picklist'),
buttons = root.querySelectorAll('.pick-option')
current_el.addEventListener('click', function(ev) {
picklist_el.classList.add('show')
})
for (let b of buttons) {
b.addEventListener('click', function(ev) {
current_el.innerText = this.innerText
current_el.setAttribute('class', `pick-current pick-${ this.innerText}`)
picklist_el.classList.remove('show')
root.dispatchEvent(new CustomEvent('colorpick', { bubbles: true, composed: true, detail: this.innerText }))
})
}
}
attributeChangedCallback(name, oldValue, newValue) {
if (newValue === '') {
const current_el = this.shadowRoot.querySelector('.pick-current')
current_el.setAttribute('class', 'pick-current')
current_el.innerText = '0'
}
}
}
customElements.define('color-picker', ColorPicker)
</script>
<!----------------->
<!-- Main script -->
<!----------------->
<script>
// Data
let win = null,
sequence = [],
code_track = [],
hint_track = []
const code_track_el = document.querySelector('code-track'),
hint_track_el = document.querySelector('hint-track'),
game_over_el = document.querySelector('game-over')
// Methods
const startGame = function() {
confetti.remove()
win = null
code_track = []
hint_track = []
code_track_el.setAttribute('guess-list', JSON.stringify(code_track))
hint_track_el.setAttribute('hint-list', JSON.stringify(hint_track))
game_over_el.setAttribute('game-result', JSON.stringify({win: null}))
sequence = createRandomSequence()
location.hash = 'game'
}
const makeGuess = function(guess) {
// Update code track
code_track.push(guess)
code_track_el.setAttribute('guess-list', JSON.stringify(code_track))
// Create hints from guess and update hint track
hint_track.push( parseGuess(guess, sequence) )
hint_track_el.setAttribute('hint-list', JSON.stringify(hint_track))
// Check for game over
win = checkForGameOver(hint_track, code_track)
if (win !== null) {
const result = {
win: win,
guesses: code_track.length,
last_guess: code_track[code_track.length - 1]
}
game_over_el.setAttribute('game-result', JSON.stringify(result))
}
}
const createRandomSequence = function() {
let seq = []
for (let idx = 0; idx < 4; idx++) {
seq.push(Math.floor(Math.random() * 6 + 1))
}
return seq
}
const parseGuess = function(guess, sequence) {
let guess_slice = guess.slice(),
seq_slice = sequence.slice(),
hints = []
for (let g in guess) {
if (guess[g] === sequence[g]) {
// Both value and position are right
// Set 'black' hint and resolve from guesses
guess_slice[g] = 'black'
seq_slice[g] = 'black'
hints.push('black')
}
}
for (let g in guess_slice) {
for (let s in seq_slice) {
if (typeof guess_slice[g] === 'number' && guess_slice[g] === seq_slice[s]) {
// Value exists in another position
// Set 'white' hint and resolve from guesses
guess_slice[g] = 'white'
seq_slice[s] = 'white'
hints.push('white')
}
}
}
return hints
}
const checkForGameOver = function(hints, codes) {
if (codes.length >= 12) {
// 12 attempts have been made
// You loose
return false
}
// JSON strings are easier to compare
const last_hints = JSON.stringify(hints[hints.length - 1]),
correct_hints = JSON.stringify(['black', 'black', 'black', 'black'])
if (last_hints === correct_hints) {
// Last guess (codes) corresponds to sequence
// You win
return true
} else {
// Game continues
return null
}
}
// Initialize
window.onload = function() {
location.hash = 'welcome'
}
document.addEventListener('guess', function(ev) {
makeGuess(ev.detail)
})
// Confetti.js
// MIT License
// Copyright (c) 2018 MathuSum Mut
var confetti={maxCount:150,speed:2,frameInterval:15,alpha:1,gradient:!1,start:null,stop:null,toggle:null,pause:null,resume:null,togglePause:null,remove:null,isPaused:null,isRunning:null};!function(){confetti.start=s,confetti.stop=w,confetti.toggle=function(){e?w():s()},confetti.pause=u,confetti.resume=m,confetti.togglePause=function(){i?m():u()},confetti.isPaused=function(){return i},confetti.remove=function(){stop(),i=!1,a=[]},confetti.isRunning=function(){return e};var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame,n=["rgba(30,144,255,","rgba(107,142,35,","rgba(255,215,0,","rgba(255,192,203,","rgba(106,90,205,","rgba(173,216,230,","rgba(238,130,238,","rgba(152,251,152,","rgba(70,130,180,","rgba(244,164,96,","rgba(210,105,30,","rgba(220,20,60,"],e=!1,i=!1,o=Date.now(),a=[],r=0,l=null;function d(t,e,i){return t.color=n[Math.random()*n.length|0]+(confetti.alpha+")"),t.color2=n[Math.random()*n.length|0]+(confetti.alpha+")"),t.x=Math.random()*e,t.y=Math.random()*i-i,t.diameter=10*Math.random()+5,t.tilt=10*Math.random()-10,t.tiltAngleIncrement=.07*Math.random()+.05,t.tiltAngle=Math.random()*Math.PI,t}function u(){i=!0}function m(){i=!1,c()}function c(){if(!i)if(0===a.length)l.clearRect(0,0,window.innerWidth,window.innerHeight),null;else{var n=Date.now(),u=n-o;(!t||u>confetti.frameInterval)&&(l.clearRect(0,0,window.innerWidth,window.innerHeight),function(){var t,n=window.innerWidth,i=window.innerHeight;r+=.01;for(var o=0;o<a.length;o++)t=a[o],!e&&t.y<-15?t.y=i+100:(t.tiltAngle+=t.tiltAngleIncrement,t.x+=Math.sin(r)-.5,t.y+=.5*(Math.cos(r)+t.diameter+confetti.speed),t.tilt=15*Math.sin(t.tiltAngle)),(t.x>n+20||t.x<-20||t.y>i)&&(e&&a.length<=confetti.maxCount?d(t,n,i):(a.splice(o,1),o--))}(),function(t){for(var n,e,i,o,r=0;r<a.length;r++){if(n=a[r],t.beginPath(),t.lineWidth=n.diameter,i=n.x+n.tilt,e=i+n.diameter/2,o=n.y+n.tilt+n.diameter/2,confetti.gradient){var l=t.createLinearGradient(e,n.y,i,o);l.addColorStop("0",n.color),l.addColorStop("1.0",n.color2),t.strokeStyle=l}else t.strokeStyle=n.color;t.moveTo(e,n.y),t.lineTo(i,o),t.stroke()}}(l),o=n-u%confetti.frameInterval),requestAnimationFrame(c)}}function s(t,n,o){var r=window.innerWidth,u=window.innerHeight;window.requestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,confetti.frameInterval)};var m=document.getElementById("confetti-canvas");null===m?((m=document.createElement("canvas")).setAttribute("id","confetti-canvas"),m.setAttribute("style","display:block;z-index:999999;pointer-events:none;position:fixed;top:0"),document.body.prepend(m),m.width=r,m.height=u,window.addEventListener("resize",function(){m.width=window.innerWidth,m.height=window.innerHeight},!0),l=m.getContext("2d")):null===l&&(l=m.getContext("2d"));var s=confetti.maxCount;if(n)if(o)if(n==o)s=a.length+o;else{if(n>o){var f=n;n=o,o=f}s=a.length+(Math.random()*(o-n)+n|0)}else s=a.length+n;else o&&(s=a.length+o);for(;a.length<s;)a.push(d({},r,u));e=!0,i=!1,c(),t&&window.setTimeout(w,t)}function w(){e=!1}}();
</script>
</body>
</html>