aboutsummaryrefslogtreecommitdiffstats
path: root/src/clip.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/clip.js')
-rw-r--r--src/clip.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/clip.js b/src/clip.js
index 189b62c..2266adb 100644
--- a/src/clip.js
+++ b/src/clip.js
@@ -13,3 +13,21 @@ SVG.Clip.prototype = new SVG.Element();
// include the container object
SVG.extend(SVG.Clip, SVG.Container);
+
+// add clipping functionality to element
+SVG.extend(SVG.Element, {
+
+ // clip element using another element
+ clip: function(block) {
+ var p = this.mother().defs().clipPath();
+ block(p);
+
+ return this.clipTo(p);
+ },
+
+ // distribute clipping path to svg element
+ clipTo: function(p) {
+ return this.attr('clip-path', 'url(#' + p.id + ')');
+ }
+
+});