8
8
< meta name ="keywords " content ="canvas,confetti,component,module,animation,javascript,catdad ">
9
9
10
10
< meta name ="theme-color " content ="#393939 ">
11
+ < link id ="favicon " rel ="shortcut icon " type ="image/png " />
11
12
12
- < title > 🎊 </ title >
13
+ < title > canvas confetti </ title >
13
14
14
15
< link href ="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap " rel ="stylesheet ">
15
16
49
50
[data-theme = "light" ][auto-theme ] {
50
51
--theme-switch : var (--switch-auto-black );
51
52
}
53
+
54
+ html {
55
+ scroll-behavior : smooth;
56
+ }
52
57
53
58
html , body {
54
59
margin : 0 ;
@@ -417,10 +422,10 @@ <h2><a href="#realistic" id="realistic" class="anchor">Realistic Look</a></h2>
417
422
</ div >
418
423
419
424
< div class ="container ">
420
- < div class ="group " data-name ="stars ">
425
+ < div class ="group " data-name ="fireworks ">
421
426
< div class ="flex-rows ">
422
427
< div class ="left ">
423
- < h2 > < a href ="#stars " id ="stars " class ="anchor "> Stars </ a > </ h2 >
428
+ < h2 > < a href ="#fireworks " id ="fireworks " class ="anchor "> Fireworks </ a > </ h2 >
424
429
< button class ="run ">
425
430
Run
426
431
< span class ="icon ">
@@ -430,22 +435,20 @@ <h2><a href="#stars" id="stars" class="anchor">Stars</a></h2>
430
435
</ div >
431
436
< div class ="description ">
432
437
< p >
433
- You can combine multiple calls to confetti with any settings in order to create
434
- a more complex effect. Go ahead, combine different shapes, sizes, etc. Stagger them
435
- for an extra boost of excitement.
438
+ Why click a button repeatedly when you can have code do it for you? Shoot some firework
439
+ of confetti from the sides of page so you can still read the content in the center.
436
440
</ p >
437
- < p class ="center "> ✨ Celebrate with a burst of stars! ✨</ p >
438
441
</ div >
439
442
</ div >
440
443
< div class ="editor "> </ div >
441
444
</ div >
442
445
</ div >
443
446
444
447
< div class ="container ">
445
- < div class ="group " data-name ="fireworks ">
448
+ < div class ="group " data-name ="stars ">
446
449
< div class ="flex-rows ">
447
450
< div class ="left ">
448
- < h2 > < a href ="#fireworks " id ="fireworks " class ="anchor "> Fireworks </ a > </ h2 >
451
+ < h2 > < a href ="#stars " id ="stars " class ="anchor "> Stars </ a > </ h2 >
449
452
< button class ="run ">
450
453
Run
451
454
< span class ="icon ">
@@ -455,9 +458,11 @@ <h2><a href="#fireworks" id="fireworks" class="anchor">Fireworks</a></h2>
455
458
</ div >
456
459
< div class ="description ">
457
460
< p >
458
- Why click a button repeatedly when you can have code do it for you? Shoot some firework
459
- of confetti from the sides of page so you can still read the content in the center.
461
+ You can combine multiple calls to confetti with any settings in order to create
462
+ a more complex effect. Go ahead, combine different shapes, sizes, etc. Stagger them
463
+ for an extra boost of excitement.
460
464
</ p >
465
+ < p class ="center "> ✨ Celebrate with a burst of stars! ✨</ p >
461
466
</ div >
462
467
</ div >
463
468
< div class ="editor "> </ div >
@@ -859,10 +864,10 @@ <h2><a href="#custom-canvas" id="custom-canvas" class="anchor">Custom Canvas</a>
859
864
860
865
var defaults = {
861
866
scalar : 2 ,
862
- spread : 270 ,
863
- particleCount : 25 ,
864
- origin : { y : 0.4 } ,
865
- startVelocity : 35
867
+ spread : 180 ,
868
+ particleCount : 30 ,
869
+ origin : { y : - 0.1 } ,
870
+ startVelocity : - 35
866
871
} ;
867
872
868
873
confetti ( {
@@ -973,6 +978,21 @@ <h2><a href="#custom-canvas" id="custom-canvas" class="anchor">Custom Canvas</a>
973
978
} ;
974
979
</ script >
975
980
981
+ < script >
982
+ // render favicon live, because why not
983
+ addEventListener ( "load" , ( event ) => {
984
+ const image = confetti . shapeFromText ( '🎊' , { scalar : 512 / 10 } ) ;
985
+ const canvas = new OffscreenCanvas ( image . bitmap . width , image . bitmap . height ) ;
986
+ const ctx = canvas . getContext ( 'bitmaprenderer' ) ;
987
+ ctx . transferFromImageBitmap ( image . bitmap ) ;
988
+
989
+ canvas . convertToBlob ( ) . then ( blob => {
990
+ const icon = document . getElementById ( 'favicon' ) ;
991
+ icon . setAttribute ( 'href' , URL . createObjectURL ( blob ) ) ;
992
+ } ) ;
993
+ } ) ;
994
+ </ script >
995
+
976
996
< script src ="/analytics.js " async > </ script >
977
997
</ body >
978
998
</ html >
0 commit comments