use NUM_FRACTION_DIGIT

This commit is contained in:
Andrea Bogazzi 2015-12-08 11:56:58 +01:00
parent f7f64d9ea2
commit 2dfc5b9fbd

View file

@ -3,7 +3,8 @@
'use strict';
var fabric = global.fabric || (global.fabric = { }),
toFixed = fabric.util.toFixed;
toFixed = fabric.util.toFixed,
NUM_FRACTION_DIGIT = fabric.Object.NUM_FRACTION_DIGITS;
if (fabric.Shadow) {
fabric.warn('fabric.Shadow is already defined.');
@ -118,16 +119,17 @@
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(offset.x) + this.blur) / object.width, 2) * 100 + 20;
fBoxY = toFixed((Math.abs(offset.y) + this.blur) / object.height, 2) * 100 + 20;
fBoxX = toFixed((Math.abs(offset.x) + this.blur) / object.width, NUM_FRACTION_DIGIT) * 100 + 20;
fBoxY = toFixed((Math.abs(offset.y) + this.blur) / object.height, NUM_FRACTION_DIGIT) * 100 + 20;
}
return (
'<filter id="SVGID_' + this.id + '" y="-' + fBoxY + '%" height="' + (100 + 2 * fBoxY) + '%" ' +
'x="-' + fBoxX + '%" width="' + (100 + 2 * fBoxX) + '%" ' + '>\n' +
'\t<feGaussianBlur in="SourceAlpha" stdDeviation="' +
toFixed(this.blur ? this.blur / 2 : 0, 3) + '"></feGaussianBlur>\n' +
'\t<feOffset dx="' + offset.x + '" dy="' + offset.y + '" result="oBlur" ></feOffset>\n' +
toFixed(this.blur ? this.blur / 2 : 0, NUM_FRACTION_DIGIT) + '"></feGaussianBlur>\n' +
'\t<feOffset dx="' + toFixed(offset.x, NUM_FRACTION_DIGIT) +
'" dy="' + toFixed(offset.y, NUM_FRACTION_DIGIT) + '" result="oBlur" ></feOffset>\n' +
'\t<feFlood flood-color="' + this.color + '"/>\n' +
'\t<feComposite in2="oBlur" operator="in" />\n' +
'\t<feMerge>\n' +