diff --git a/src/shadow.class.js b/src/shadow.class.js index db644b690e8..45ce75c9ff5 100644 --- a/src/shadow.class.js +++ b/src/shadow.class.js @@ -123,7 +123,12 @@ fBoxX = toFixed((Math.abs(offset.x) + this.blur) / object.width, NUM_FRACTION_DIGITS) * 100 + BLUR_BOX; fBoxY = toFixed((Math.abs(offset.y) + this.blur) / object.height, NUM_FRACTION_DIGITS) * 100 + BLUR_BOX; } - + if (object.flipX) { + offset.x *= -1; + } + if (object.flipY) { + offset.y *= -1; + } return ( '\n' + diff --git a/test/unit/shadow.js b/test/unit/shadow.js index 4f7d48130df..21421c4fec6 100644 --- a/test/unit/shadow.js +++ b/test/unit/shadow.js @@ -170,6 +170,17 @@ shadow.color = '#000000'; equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); }); + + test('toSVG with flipped object', function() { + // reset uid + fabric.Object.__uid = 0; + + var shadow = new fabric.Shadow({color: '#FF0000', offsetX: 10, offsetY: -10, blur: 2}); + var object = new fabric.Object({fill: '#FF0000', flipX: true, flipY: true}); + + equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); + + }); test('toSVG with rotated object', function() { // reset uid @@ -180,5 +191,15 @@ equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); }); + + test('toSVG with rotated flipped object', function() { + // reset uid + fabric.Object.__uid = 0; + + var shadow = new fabric.Shadow({color: '#FF0000', offsetX: 10, offsetY: 10, blur: 2}); + var object = new fabric.Object({fill: '#FF0000', angle: 45, flipX: true}); + + equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); + }); })();