From b9f37586b3fe043ceb5e18d85edb24802a967294 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Tue, 21 Oct 2014 22:50:34 +0200 Subject: [PATCH] Update text.js --- src/canvas.class.js | 2 +- src/shadow.class.js | 28 ++++++++++++++++++---------- test/unit/shadow.js | 4 ++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/canvas.class.js b/src/canvas.class.js index fc62aeae..32cfdd6b 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -649,7 +649,7 @@ angle = 360 + angle; } - t.target.angle = angle; + t.target.angle = angle % 360; }, /** 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'); }); })();