Setting up P5.js on the blog
Karthik Perla | Jun 2022 | Reading time: 1 minSites that have been used to integrate p5js on the page:
Then, I implemented a widget. Setting up p5js widgets: guide to the setup
In order to include a P5.js sketch in the post:
- Import the p5.js library as a dependency. You can complete the front-matter of the post like this:
- create in
div
in the markdown document of your post and include the javascript file (relative path from the markdown document). Note that we gave thediv
a custom id.
- in your javascript file, make sure to link the canvas to this specific
div
. See the documentation for more information.
Note: using the method, you can only include a single sketch per file. See here if you want to have several sketches running simultaneously.