Skip to content

Commit

Permalink
adding a runtime-generated favicon, just because I can
Browse files Browse the repository at this point in the history
  • Loading branch information
catdad committed Oct 5, 2023
1 parent 9c7c047 commit 8188564
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
<meta name="keywords" content="canvas,confetti,component,module,animation,javascript,catdad">

<meta name="theme-color" content="#393939">
<link id="favicon" rel="shortcut icon" type="image/png" />

<title>🎊</title>
<title>canvas confetti</title>

<link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet">

Expand Down Expand Up @@ -973,6 +974,21 @@ <h2><a href="#custom-canvas" id="custom-canvas" class="anchor">Custom Canvas</a>
};
</script>

<script>
// render favicon live, because why not
addEventListener("load", (event) => {
const image = confetti.shapeFromText('🎊', { scalar: 512/10 });
const canvas = new OffscreenCanvas(image.bitmap.width, image.bitmap.height);
const ctx = canvas.getContext('bitmaprenderer');
ctx.transferFromImageBitmap(image.bitmap);

canvas.convertToBlob().then(blob => {
const icon = document.getElementById('favicon');
icon.setAttribute('href', URL.createObjectURL(blob));
});
});
</script>

<script src="/analytics.js" async></script>
</body>
</html>

0 comments on commit 8188564

Please sign in to comment.