p5.js
p5.js copied to clipboard
Fix ellipseMode(CORNERS) and rectMode(CORNER)
Resolves #7289
Changes:
This mainly resolves a rendering/crashing issues with ellipseMode(CORNERS) affecting ellipse() and arc(); see issue above). It also fixes a related issue with using rectMode(CORNER) and negative widths and/or heights.
The bulk of the changes are in modeAdjust() which should now properly handle the modes and return a normalized bounding box. As a result a few lines of handling negative widths and heights needed to be removed from arc() and _renderEllipse().
I've included a test sketch in test/shape-modes.html where you can cycle through all the different modes and shapes. I'm happy to update this, if somebody could direct me on how to properly test this case. I'm not sure, since it's mostly about the rendering output.
Screenshots of the change:
PR Checklist
- [x]
npm run lintpasses - [x] Inline documentation is included / updated
- [x] Unit tests are included / updated
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page!
Hi, Thanks for taking up this task. I believe I have tested this and it works well. I have a concern: are you planning to write tests for it in the test/shape-modes.html file?
If so, I don't think that approach would work for your case. Perhaps we could write unit or visual tests instead. What's your opinion?
Hi, I've added proper visual test and removed test/shape-modes.html. I had to update test/node/helpers.js (the test for modeAdjust() as well. npm run test passes all tests now. Please have a look and let me know if that works.
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page!
@all-contributors please add @martinleopold for bug, code