diff --git a/src/shadow.class.js b/src/shadow.class.js
index 7731f0ef..bafe70dc 100644
--- a/src/shadow.class.js
+++ b/src/shadow.class.js
@@ -110,23 +110,31 @@
* @return {String} SVG representation of a shadow
*/
toSVG: function(object) {
- var mode = 'SourceAlpha';
+ var mode = 'SourceAlpha', fBoxX = 40, fBoxY = 40;
if (object && (object.fill === this.color || object.stroke === this.color)) {
mode = 'SourceGraphic';
}
+ if (object.width && object.height) {
+ //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion
+ // we add some extra space to filter box to contain the blur ( 20 )
+ fBoxX = Math.abs(this.offsetX / object.getWidth()) * 100 + 20;
+ fBoxY = Math.abs(this.offsetY / object.getHeight()) * 100 + 20;
+ }
+
return (
- '' +
- '\n' +
+ '\t' +
- '' +
- '' +
- '' +
- '' +
- '' +
- '');
+ '">\n' +
+ '\t\n' +
+ '\t\n' +
+ '\t\t\n' +
+ '\t\t\n' +
+ '\t\n' +
+ '\n');
},
/* _TO_SVG_END_ */
diff --git a/test/unit/shadow.js b/test/unit/shadow.js
index 100e767d..ddcfb79c 100644
--- a/test/unit/shadow.js
+++ b/test/unit/shadow.js
@@ -155,10 +155,10 @@
var shadow = new fabric.Shadow({color: '#FF0000', offsetX: 10, offsetY: -10, blur: 2});
var object = new fabric.Object({fill: '#FF0000'});
- equal(shadow.toSVG(object), '');
+ equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n');
shadow.color = '#000000';
- equal(shadow.toSVG(object), '');
+ equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n');
});
})();