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

Add an overload to image() for using fitting arguments without cropping

Open tetrogem opened this issue 3 years ago • 0 comments
trafficstars

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
  • [X] 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)

tetrogem avatar Sep 16 '22 15:09 tetrogem