Created
May 8, 2025 09:23
-
-
Save dobladov/ce9cd13a266980c792a82d0e2899493b to your computer and use it in GitHub Desktop.
Example of q5.js in an astro component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="canvas" id="canvasContainer" /> | |
| <script> | |
| import 'q5'; | |
| const canvasContainer = document.getElementById('canvasContainer'); | |
| if (!(canvasContainer instanceof HTMLElement)) { | |
| throw new Error('Canvas container not found'); | |
| } | |
| let q = new Q5('instance', canvasContainer); | |
| const containerWidth = canvasContainer.clientWidth; | |
| q.createCanvas(containerWidth, 500); | |
| q.draw = () => { | |
| q.background(0.8); | |
| q.circle(q.mouseX, q.mouseY, 80); | |
| }; | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment