Merge pull request #1931 from asturur/shadow

Fix Shadow svg output
This commit is contained in:
Juriy Zaytsev 2015-01-18 17:29:35 +01:00
commit 64515eb3e9
2 changed files with 9 additions and 6 deletions

View file

@ -1,5 +1,6 @@
**Edge**
- Added image preserve aspect ratio attributes and functionality (fabric.Image.alignY, fabric.Image.alignY, fabric.Image.meetOrSlic )
- Added ImageResizeFilters , option to resize dinamically or statically the images using a set of resize filter alghoritms.
- [BACK_INCOMPAT] `fabric.Collection#remove` doesn't return removed object -> returns `this` (chainable)
- Add "mouse:over" and "mouse:out" canvas events (and corresponding "mouseover", "mouseout" object events)

View file

@ -2,7 +2,8 @@
'use strict';
var fabric = global.fabric || (global.fabric = { });
var fabric = global.fabric || (global.fabric = { }),
toFixed = fabric.util.toFixed;
if (fabric.Shadow) {
fabric.warn('fabric.Shadow is already defined.');
@ -119,16 +120,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 = Math.abs(this.offsetX / object.getWidth()) * 100 + 20;
fBoxY = Math.abs(this.offsetY / object.getHeight()) * 100 + 20;
fBoxX = toFixed(Math.abs(this.offsetX / object.getWidth()), 2) * 100 + 20;
fBoxY = toFixed(Math.abs(this.offsetY / object.getHeight()), 2) * 100 + 20;
}
return (
'<filter id="SVGID_' + this.id + '" y="-' + fBoxY + '%" height="' + (100 + 2 * fBoxY) + '%" ' +
'x="-' + fBoxX + '%" width="' + (100 + 2 * fBoxX) + '%" ' + '>\n' +
'\t<feGaussianBlur in="' + mode + '" stdDeviation="' +
(this.blur ? this.blur / 3 : 0) +
'"></feGaussianBlur>\n' +
toFixed(this.blur ? this.blur / 2 : 0, 3) +
'" result="blurOut"></feGaussianBlur>\n' +
'\t<feColorMatrix result="matrixOut" in="blurOut" type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.30 0" /></feColorMatrix >\n' +
'\t<feOffset dx="' + this.offsetX + '" dy="' + this.offsetY + '"></feOffset>\n' +
'\t<feMerge>\n' +
'\t\t<feMergeNode></feMergeNode>\n' +