diff --git a/src/shapes/object.class.js b/src/shapes/object.class.js index 73f8af43a04..a12df6e9183 100644 --- a/src/shapes/object.class.js +++ b/src/shapes/object.class.js @@ -1719,9 +1719,10 @@ options || (options = { }); var utils = fabric.util, origParams = utils.saveObjectTransform(this), + originalGroup = this.group, originalShadow = this.shadow, abs = Math.abs, multiplier = (options.multiplier || 1) * (options.enableRetinaScaling ? fabric.devicePixelRatio : 1); - + delete this.group; if (options.withoutTransform) { utils.resetObjectTransform(this); } @@ -1743,6 +1744,7 @@ else { scaling = this.getObjectScaling(); } + // consider non scaling shadow. shadowOffset.x = 2 * Math.round(abs(shadow.offsetX) + shadowBlur) * (abs(scaling.scaleX)); shadowOffset.y = 2 * Math.round(abs(shadow.offsetY) + shadowBlur) * (abs(scaling.scaleY)); } @@ -1765,6 +1767,9 @@ var canvasEl = canvas.toCanvasElement(multiplier || 1, options); this.shadow = originalShadow; this.canvas = originalCanvas; + if (originalGroup) { + this.group = originalGroup; + } this.set(origParams).setCoords(); // canvas.dispose will call image.dispose that will nullify the elements // since this canvas is a simple element for the process, we remove references diff --git a/test/visual/generic_rendering.js b/test/visual/generic_rendering.js index b8c5b9f2bd9..309a47b669f 100644 --- a/test/visual/generic_rendering.js +++ b/test/visual/generic_rendering.js @@ -242,5 +242,23 @@ height: 300, }); + function objectsInActiveSelections(canvas, callback) { + canvas.setZoom(0.1); + var rect1 = new fabric.Rect({ fill: 'purple', top: 30, left: 50, width: 30, height: 100, angle: 10 }); + var rect2 = new fabric.Rect({ fill: 'green', top: 150, left: 10, width: 300, height: 30, angle: -10 }); + new fabric.ActiveSelection([rect1, rect2]); + var output = rect1.toCanvasElement(); + callback(output); + } + + tests.push({ + test: 'objects in activeSelection toCanvasElement', + code: objectsInActiveSelections, + golden: 'objectsInActiveSelections.png', + percentage: 0.09, + width: 300, + height: 300, + }); + tests.forEach(visualTestLoop(QUnit)); })(); diff --git a/test/visual/golden/objectsInActiveSelections.png b/test/visual/golden/objectsInActiveSelections.png new file mode 100644 index 00000000000..d4f5abc1714 Binary files /dev/null and b/test/visual/golden/objectsInActiveSelections.png differ