MCPcopy Index your code
hub / github.com/processing/p5.js / _imageFit

Function _imageFit

src/image/loading_displaying.js:795–826  ·  view source on GitHub ↗

* @private * @param {(CONTAIN|COVER)} [fit] either CONTAIN or COVER * @param {(LEFT|RIGHT|CENTER)} xAlign either LEFT, RIGHT or CENTER * @param {(TOP|BOTTOM|CENTER)} yAlign either TOP, BOTTOM or CENTER * @param {Number} dx * @param {Number} dy * @param {Number} dw * @param {Numb

(fit, xAlign, yAlign, dx, dy, dw, dh, sx, sy, sw, sh)

Source from the content-addressed store, hash-verified

793 * @returns {Object}
794 */
795 function _imageFit(fit, xAlign, yAlign, dx, dy, dw, dh, sx, sy, sw, sh) {
796 if (fit === constants.COVER) {
797 const { x, y, w, h } = _imageCover(
798 xAlign, yAlign,
799 dw, dh,
800 sx, sy,
801 sw, sh
802 );
803 sx = x;
804 sy = y;
805 sw = w;
806 sh = h;
807 }
808
809 if (fit === constants.CONTAIN) {
810 const { x, y, w, h } = _imageContain(
811 xAlign,
812 yAlign,
813 dx,
814 dy,
815 dw,
816 dh,
817 sw,
818 sh
819 );
820 dx = x;
821 dy = y;
822 dw = w;
823 dh = h;
824 }
825 return { sx, sy, sw, sh, dx, dy, dw, dh };
826 }
827
828 /**
829 * Validates clipping params. Per drawImage spec sWidth and sHight cannot be

Callers 1

loadingDisplayingFunction · 0.85

Calls 2

_imageCoverFunction · 0.85
_imageContainFunction · 0.85

Tested by

no test coverage detected