diff --git a/src/core/view/components/canvas/index.vue b/src/core/view/components/canvas/index.vue index 491dc871299e400d12e49682fb83149a66be9c9e..3167fa0035bc59ee66d873ac4f4849039d3d2953 100644 --- a/src/core/view/components/canvas/index.vue +++ b/src/core/view/components/canvas/index.vue @@ -365,12 +365,10 @@ export default { }) { const canvas = this.$refs.canvas let data - if (!width) { - width = canvas.offsetWidth - x - } - if (!height) { - height = canvas.offsetHeight - y - } + const maxWidth = canvas.offsetWidth - x + width = width ? Math.min(width, maxWidth) : maxWidth + const maxHeight = canvas.offsetHeight - y + height = height ? Math.min(height, maxWidth) : maxHeight if (!hidpi) { if (!destWidth && !destHeight) { destWidth = Math.round(width * pixelRatio)