This is an example of how to use Quil in a way that lets you:
- Have multiple sketches
- An ability to switch between them with automatic pausing/resuming
- Hot code reloading without unnecessary state loss and an ability to add/remove sketches without reloading the page
Requirements:
After you got those, run in your terminal:
npm i
npx shadow-cljs watch main
and follow the URL that shadow-cljs prints.
Usually it's http://localhost:8000 but it can have a different port if 8000
is already taken.
- Add a namespace somewhere (probably to
src/quil_sketchbook/sketches
) - Write some basic Quil sketch code with a function that accepts a DOM node and returns a new sketch
Note that you should pass:update
and:draw
functions toquil.core/sketch
with a preceding#'
to support hot code reloading for those functions.
Check out the existing examples insrc/quil_sketchbook/sketches
to get a feel of what it should look like. - Require that sketch namespace in
src/quil_sketchbook/sketches.cljs
and add the aforementioned function to the only vector in that file