From 67d367e0d74b3287956130da0077e42c6483dd2f Mon Sep 17 00:00:00 2001 From: wout Date: Sun, 24 Mar 2013 19:19:06 +0100 Subject: Bumped to v0.11 - removed SVG.Wrap on SVG.Polyline, SVG.Polygon and SVG.Path - added delay on SVG.FX module - made x(), y(), cx() and cy() as getters - added SGB.get() method, to get elements by a DOM id - fixed bug in remove() method on container elements - added jasmine test suite to repo --- src/clip.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/clip.js (limited to 'src/clip.js') diff --git a/src/clip.js b/src/clip.js new file mode 100644 index 0000000..9562162 --- /dev/null +++ b/src/clip.js @@ -0,0 +1,28 @@ + +SVG.Clip = function Clip() { + this.constructor.call(this, SVG.create('clipPath')) +} + +// Inherit from SVG.Container +SVG.Clip.prototype = new SVG.Container + +SVG.extend(SVG.Element, { + + // Distribute clipPath to svg element + clipWith: function(element) { + /* use given clip or create a new one */ + this.clip = element instanceof SVG.Clip ? element : this.parent.clip().add(element) + + return this.attr('clip-path', 'url(#' + this.clip.attr('id') + ')') + } + +}) + +// Add container method +SVG.extend(SVG.Container, { + // Create clipping element + clip: function() { + return this.defs().put(new SVG.Clip) + } + +}) -- cgit v1.2.3