From 576f34ab685b36c353d929568e9512e8c60ba48e Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 30 Dec 2018 18:12:41 +0100 Subject: [PATCH] small-changes (#5454) --- src/mixins/canvas_dataurl_exporter.mixin.js | 11 ++++++++--- src/mixins/object_geometry.mixin.js | 2 +- src/shapes/object.class.js | 15 ++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/mixins/canvas_dataurl_exporter.mixin.js b/src/mixins/canvas_dataurl_exporter.mixin.js index 477cf028a6a..e4ad0f706b3 100644 --- a/src/mixins/canvas_dataurl_exporter.mixin.js +++ b/src/mixins/canvas_dataurl_exporter.mixin.js @@ -65,25 +65,30 @@ var scaledWidth = (cropping.width || this.width) * multiplier, scaledHeight = (cropping.height || this.height) * multiplier, zoom = this.getZoom(), + originalWidth = this.width, + originalHeight = this.height, newZoom = zoom * multiplier, vp = this.viewportTransform, translateX = (vp[4] - (cropping.left || 0)) * multiplier, translateY = (vp[5] - (cropping.top || 0)) * multiplier, originalInteractive = this.interactive, - originalOffscreen = this.skipOffscreen, originalContext = this.contextContainer, newVp = [newZoom, 0, 0, newZoom, translateX, translateY], canvasEl = fabric.util.createCanvasElement(); canvasEl.width = scaledWidth; canvasEl.height = scaledHeight; - this.skipOffscreen = false; this.interactive = false; this.viewportTransform = newVp; + this.width = scaledWidth; + this.height = scaledHeight; + this.calcViewportBoundaries(); this.contextContainer = canvasEl.getContext('2d'); // will be renderAllExport(); this.renderAll(); this.viewportTransform = vp; - this.skipOffscreen = originalOffscreen; + this.width = originalWidth; + this.height = originalHeight; + this.calcViewportBoundaries(); this.contextContainer = originalContext; this.interactive = originalInteractive; return canvasEl; diff --git a/src/mixins/object_geometry.mixin.js b/src/mixins/object_geometry.mixin.js index b99aa3239fc..00f8d448ba8 100644 --- a/src/mixins/object_geometry.mixin.js +++ b/src/mixins/object_geometry.mixin.js @@ -160,7 +160,7 @@ /** * Checks if object is contained within the canvas with current viewportTransform * the check is done stopping at first point that appears on screen - * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @param {Boolean} [calculate] use coordinates of current position instead of .aCoords * @return {Boolean} true if object is fully or partially contained within canvas */ isOnScreen: function(calculate) { diff --git a/src/shapes/object.class.js b/src/shapes/object.class.js index 8feec9d947a..9ff0eedc66b 100644 --- a/src/shapes/object.class.js +++ b/src/shapes/object.class.js @@ -1366,18 +1366,19 @@ return; } - var multX = (this.canvas && this.canvas.viewportTransform[0]) || 1, - multY = (this.canvas && this.canvas.viewportTransform[3]) || 1, + var shadow = this.shadow, canvas = this.canvas, + multX = (canvas && canvas.viewportTransform[0]) || 1, + multY = (canvas && canvas.viewportTransform[3]) || 1, scaling = this.getObjectScaling(); - if (this.canvas && this.canvas._isRetinaScaling()) { + if (canvas && canvas._isRetinaScaling()) { multX *= fabric.devicePixelRatio; multY *= fabric.devicePixelRatio; } - ctx.shadowColor = this.shadow.color; - ctx.shadowBlur = this.shadow.blur * fabric.browserShadowBlurConstant * + ctx.shadowColor = shadow.color; + ctx.shadowBlur = shadow.blur * fabric.browserShadowBlurConstant * (multX + multY) * (scaling.scaleX + scaling.scaleY) / 4; - ctx.shadowOffsetX = this.shadow.offsetX * multX * scaling.scaleX; - ctx.shadowOffsetY = this.shadow.offsetY * multY * scaling.scaleY; + ctx.shadowOffsetX = shadow.offsetX * multX * scaling.scaleX; + ctx.shadowOffsetY = shadow.offsetY * multY * scaling.scaleY; }, /**