p5 runner
A tool for running and exporting p5.js sketches in a modern ESNext environment.
As soon as you make changes to your sketch file, this package will automatically reload the sketch in the browser. The tool also provides a simple API for getting animation frames out of the browser and saving them as PNG files.
Usage
npm init -y
npm install --save p5-runner
- Create index.js
const size = 512const fps = 50 const sin cos PI = Mathconst r = size / 3
npx p5-runner
ornpx p5-runner index.js
- Go to http://localhost:3000
Exporting your sketch as PNG files
Calling the api.saveFrame()
method in your sketch file will save the current animation frame in your project's directory. The default output location is "out/out.#####.png" but you can also provide your own destination path like this: api.saveFrame("renders/sketch01/#####.png")
or api.saveFrame("still.png")