* @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)
| 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 |
no test coverage detected