Skip to content

Instantly share code, notes, and snippets.

@dobladov
Created May 8, 2025 09:23
Show Gist options
  • Select an option

  • Save dobladov/ce9cd13a266980c792a82d0e2899493b to your computer and use it in GitHub Desktop.

Select an option

Save dobladov/ce9cd13a266980c792a82d0e2899493b to your computer and use it in GitHub Desktop.
Example of q5.js in an astro component
<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