Add an overload to image() for using fitting arguments without cropping
@linqianxuan is already working on this.
Since Oct 17, 2022.
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
Increasing Access
Many people may never need to use the cropping functionality of image(), so allowing them to use the fitting arguments without needing to include 4 extra parameters (which would always be 0, 0, img.width, img.height) will help increase accessibility to this new feature and make it easier to read and use within sketches.
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build Process
- Unit Testing
- Internalization
- Friendly Errors
- Other (specify if possible)
Feature enhancement details
With the recent fitting additions to image(), it is now possible to do the following:
image(img, 0, 0, 300, 400, 0, 0, img.width, img.height, COVER, CENTER, TOP);
This proposal is to allow a overload to this function, letting the fitting arguments (COVER, CENTER, TOP, etc.) be used without the need for the sx, sy, sWidth, and sHeight arguments:
image(img, 0, 0, 300, 400, COVER, CENTER, TOP);
This should function identically to if the user typed 0, 0, img.width, and img.height for sx, sy, sWidth, and sHeight respectively, which will make sure the entire image is drawn on screen, similar to how calling image(img, 0, 0, 300, 400) does currently.
image(img, 0, 0, 300, 400) could also be interpreted as having a default state for both the source arguments and the fit arguments, being equivalent to image(img, 0, 0, 300, 400, 0, 0, img.width, and img.height, STRETCH, TOP, LEFT) (TOP and LEFT could be replaced with anything in this instance as STRETCH always resizes the image to fit within the bounds)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.