From 87b641ef9a1d6eab1bfd2fb1bfe33cff79863919 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 28 Apr 2018 00:43:21 +0200 Subject: [PATCH] modified shadow tosvg --- src/shadow.class.js | 5 +++-- test/unit/shadow.js | 13 ++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/shadow.class.js b/src/shadow.class.js index 12cc441ff00..dc37a2543d1 100644 --- a/src/shadow.class.js +++ b/src/shadow.class.js @@ -115,7 +115,7 @@ offset = fabric.util.rotateVector( { x: this.offsetX, y: this.offsetY }, fabric.util.degreesToRadians(-object.angle)), - BLUR_BOX = 20; + BLUR_BOX = 20, color = new fabric.Color(this.color); if (object.width && object.height) { //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion @@ -129,6 +129,7 @@ if (object.flipY) { offset.y *= -1; } + return ( '\n' + @@ -136,7 +137,7 @@ toFixed(this.blur ? this.blur / 2 : 0, NUM_FRACTION_DIGITS) + '">\n' + '\t\n' + - '\t\n' + + '\t\n' + '\t\n' + '\t\n' + '\t\t\n' + diff --git a/test/unit/shadow.js b/test/unit/shadow.js index 0dd9f3a4273..e70a7f85569 100644 --- a/test/unit/shadow.js +++ b/test/unit/shadow.js @@ -165,10 +165,13 @@ var shadow = new fabric.Shadow({color: '#FF0000', offsetX: 10, offsetY: -10, blur: 2}); var object = new fabric.Object({fill: '#FF0000'}); - assert.equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); + assert.equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); + + shadow.color = 'rgba(255,0,0,0.5)'; + assert.equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); shadow.color = '#000000'; - assert.equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); + assert.equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); }); QUnit.test('toSVG with flipped object', function(assert) { @@ -178,7 +181,7 @@ var shadow = new fabric.Shadow({color: '#FF0000', offsetX: 10, offsetY: -10, blur: 2}); var object = new fabric.Object({fill: '#FF0000', flipX: true, flipY: true}); - assert.equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); + assert.equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); }); @@ -189,7 +192,7 @@ var shadow = new fabric.Shadow({color: '#FF0000', offsetX: 10, offsetY: 10, blur: 2}); var object = new fabric.Object({fill: '#FF0000', angle: 45}); - assert.equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); + assert.equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); }); QUnit.test('toSVG with rotated flipped object', function(assert) { @@ -199,7 +202,7 @@ var shadow = new fabric.Shadow({color: '#FF0000', offsetX: 10, offsetY: 10, blur: 2}); var object = new fabric.Object({fill: '#FF0000', angle: 45, flipX: true}); - assert.equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); + assert.equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); }); })();