From 66360ed33d4811d1c71007955a57c838626fc75e Mon Sep 17 00:00:00 2001 From: tanshuai Date: Wed, 1 Mar 2023 15:52:59 +0800 Subject: [PATCH] fix: add `rounded` option to `getCroppedCanvas` method (#551) --- README.md | 1 + src/js/methods.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b09a5aba3..977e3be2d 100644 --- a/README.md +++ b/README.md @@ -824,6 +824,7 @@ Change the crop box position and size with new data. - `fillColor`: a color to fill any alpha values in the output canvas, the default value is the `transparent`. - [`imageSmoothingEnabled`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled): set to change if images are smoothed (`true`, default) or not (`false`). - [`imageSmoothingQuality`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingQuality): set the quality of image smoothing, one of "low" (default), "medium", or "high". + - `rounded`: set `true` to use rounded values (the cropped area position and size data), the default value is `false`. - (return value): - Type: `HTMLCanvasElement` diff --git a/src/js/methods.js b/src/js/methods.js index 574ac2a71..b4acd8ad3 100644 --- a/src/js/methods.js +++ b/src/js/methods.js @@ -654,7 +654,7 @@ export default { y: initialY, width: initialWidth, height: initialHeight, - } = this.getData(); + } = this.getData(options.rounded || false); const ratio = source.width / Math.floor(canvasData.naturalWidth); if (ratio !== 1) {