Skip to content

Update saveFrames documentation #5694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 3, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import omggif from 'omggif';
* let img = createImage(66, 66);
* img.loadPixels();
* let d = pixelDensity();
* let halfImage = 4 * (img.width * d) * (img.height / 2 * d);
* let halfImage = 4 * (img.width * d) * ((img.height / 2) * d);
* for (let i = 0; i < halfImage; i += 4) {
* img.pixels[i] = red(pink);
* img.pixels[i + 1] = green(pink);
Expand Down Expand Up @@ -420,15 +420,20 @@ p5.prototype.saveGif = function(pImg, filename) {
* as an argument to the callback function as an array of objects, with the
* size of array equal to the total number of frames.
*
* Note that <a href="#/p5.Image/saveFrames">saveFrames()</a> will only save the first 15 frames of an animation.
* Note that <a href="#/p5.Image/saveFrames">saveFrames()</a> will only save the first 15 seconds of an animation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this line anymore with the explanations below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jesi-rgb Still have this pending then we can merge.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it and also a minor typo!

* The arguments `duration` and `framerate` are constrained to be less or equal 15 and 22, respectively, which means you
* can only download a maximum of 15 seconds worth of frames at 22 frames per second, adding up to 330 frames.
* This is done in order to avoid memory problems since a large enough canvas can fill up the memory in your computer
* very easily and crash your program or even your browser.
*
* To export longer animations, you might look into a library like
* <a href="https://github.com/spite/ccapture.js/">ccapture.js</a>.
*
* @method saveFrames
* @param {String} filename
* @param {String} extension 'jpg' or 'png'
* @param {Number} duration Duration in seconds to save the frames for.
* @param {Number} framerate Framerate to save the frames in.
* @param {Number} duration Duration in seconds to save the frames for. This parameter will be constrained to be less or equal to 15.
* @param {Number} framerate Framerate to save the frames in. This parameter will be constrained to be less or equal to 22.
* @param {function(Array)} [callback] A callback function that will be executed
to handle the image data. This function
should accept an array as argument. The
Expand Down