Repository navigation
Fix saveCanvas() when passing the canvas from createCanvas() or createGraphics() - #9384
Open
Akshats-git wants to merge 1 commit into
Open
Akshats-git wants to merge 1 commit into
Akshats-git wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #9381
Changes:
In 2.x,
createCanvas()returns ap5.RendererandcreateGraphics()returns ap5.Graphics. Neither is ap5.Elementanymore, sosaveCanvas()did not recognise them. It treated the object as the filename and threwfilename.includes is not a function. Nothing was saved.This PR adds a check for
p5.Rendererandp5.Graphicsat the start ofsaveCanvas()and uses their.canvas.save()insrc/io/files.jsalready does the same thing.src/image/image.js: handlep5.Rendererandp5.Graphicsand add them to the@paramtype.docs/parameterData.json: same type update so FES accepts these arguments.test/unit/image/downloading.js: 4 new tests on a real sketch (2D canvas, canvas with a filename and extension, WEBGL canvas,p5.Graphics). The existing tests only used a mock and never passed a canvas which is why this was missed. The new tests fail without the fix.All six examples on the
saveCanvas()reference page now save a file in Chrome and Firefox, the same as in 1.11.10.I used an AI assistant to help fix and write the tests. I have reviewed and tested every change myself.
PR Checklist
npm run lintpasses