From e41088329d404f26f99ada8d425b5499f816a6c7 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Fri, 17 Jul 2015 13:36:44 +0200 Subject: [PATCH] Update shadow.class.js --- src/shadow.class.js | 21 ++++++++------------- test/unit/shadow.js | 4 ++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/shadow.class.js b/src/shadow.class.js index 73355951..a9e2958b 100644 --- a/src/shadow.class.js +++ b/src/shadow.class.js @@ -111,28 +111,23 @@ * @return {String} SVG representation of a shadow */ toSVG: function(object) { - var mode = 'SourceAlpha', fBoxX = 40, fBoxY = 40; - - if (object && (object.fill === this.color || object.stroke === this.color)) { - mode = 'SourceGraphic'; - } + var fBoxX = 40, fBoxY = 40; 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 = toFixed(Math.abs(this.offsetX / object.getWidth()), 2) * 100 + 20; - fBoxY = toFixed(Math.abs(this.offsetY / object.getHeight()), 2) * 100 + 20; + fBoxX = toFixed((Math.abs(this.offsetX) + this.blur) / object.width, 2) * 100 + 20; + fBoxY = toFixed((Math.abs(this.offsetY) + this.blur) / object.height, 2) * 100 + 20; } return ( '\n' + - '\t\n' + - '\t\n' + - '\t\n' + + '\t\n' + + '\t\n' + + '\t\n' + + '\t\n' + '\t\n' + '\t\t\n' + '\t\t\n' + diff --git a/test/unit/shadow.js b/test/unit/shadow.js index cbd67861..713543de 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), '\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); + 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'; - equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); + equal(shadow.toSVG(object), '\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'); }); })();