p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

Fix ellipseMode(CORNERS) and rectMode(CORNER)

Open martinleopold opened this issue 1 year ago • 5 comments

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: ellipse-fix

PR Checklist

martinleopold avatar Sep 26 '24 12:09 martinleopold

🎉 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!

welcome[bot] avatar Sep 26 '24 12:09 welcome[bot]

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?

perminder-17 avatar Sep 28 '24 23:09 perminder-17

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.

martinleopold avatar Oct 03 '24 11:10 martinleopold

🎉 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

martinleopold avatar Oct 03 '24 14:10 martinleopold

@martinleopold

I've put up a pull request to add @martinleopold! :tada:

allcontributors[bot] avatar Oct 03 '24 14:10 allcontributors[bot]