Comments (2)
Thanks, I will look into this as soon as possible.
from svg.js.
Hi,
Thanks for that.
Filters should really be a part of svg.js but before this could be released it needs a lot more work.
I am still in doubt on if it should be a plugin or part of the core library.
I might go for an even more modular structure in the future.
Kind regards,
Wout
Wout Fierens
Imp. Inc. Ltd
impinc.co.uk (http://impinc.co.uk)
On Sunday, 14 April 2013 at 02:45, remy215 wrote:
Hi, great job on this library, really impressive.
I edited it to add support for filters on top of already existing support for masks.
below are the changes:
change1:// Create masking element
, mask: function() {
return this.defs().put(new SVG.Mask)
}
/*** RD-added: start _/
// Create masking element
, filter: function() {
return this.defs().put(new SVG.Filter)
}
/* RD-added: end ***/
// Create clipping element
, clip: function() {
return this.defs().put(new SVG.Clip)
}
change2:
SVG.extend(SVG.Element, {
// Distribute mask to svg element
maskWith: function(element) {
/_ use given mask or create a new one /
this.mask = element instanceof SVG.Mask ? element : this.parent.mask().add(element)
return this.attr('mask', 'url(#' + this.mask.attr('id') + ')')
}
})
/* RD-added: start */
SVG.Filter = function() {
this.constructor.call(this, SVG.create('filter'))
}
// Inherit from SVG.Container
SVG.Filter.prototype = new SVG.Container
SVG.extend(SVG.Element, {
// Distribute mask to svg element
filterWith: function(element) {
/ use given mask or create a new one /
this.filter = element instanceof SVG.Filter ? element : this.parent.filter().add(element)
return this.attr('filter', 'url(#' + this.filter.attr('id') + ')')
}
})
/* RD-added: end ****/
SVG.Clip = function() {
this.constructor.call(this, SVG.create('clipPath'))
}
Usage:var toShow = draw.image('img/IMG_2.JPG', width, height);
var filter = draw.filter();
var gauss = SVG.create('feGaussianBlur');
gauss.setAttribute('stdDeviation', 3);
filter.node.appendChild(gauss);
toShow.filterWith(filter);
This works like a charm.
Regards,
Remy—
Reply to this email directly or view it on GitHub (#23).
from svg.js.
Related Issues (20)
- Update website on node package README HOT 1
- It would be nice if we can destroy timeline gracefully. HOT 3
- Error: Unbound namespace prefix: "svgjs" HOT 8
- How to judge the <g> container exist the child element <rect>?
- npm install for nodejs HOT 1
- how to move while rotating
- Text alignment differs between 3.0 and 3.1 HOT 1
- (documentation) animating shapes along a path example needs rewrite HOT 5
- Moving a text with an inside title element fails HOT 4
- Migrating SVG window events HOT 6
- Incomplete typings - measurements should accept percentages HOT 3
- No Fragment declaration in svg.js.d.ts HOT 2
- Custom Bezier Function HOT 2
- Negative scale value in animation do not work properly. HOT 4
- TypeError: Cannot read properties of undefined (reading 'call') for PATHs in NodeJS HOT 8
- svgjs.com redirect to 'gacor.poker' scammy site HOT 1
- Image SVG size is zero sometimes HOT 4
- How can I draw a Polyline from a svg => g => svg => rect (responsive) to an Dom Element on the right side? HOT 1
- Testing overloaded methods is hard HOT 1
- Issues with rolling a timeline backwards with non-animating functions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svg.js.