aboutsummaryrefslogtreecommitdiffstats
path: root/src/mask.js
blob: 5ffd79059becd4f3ea78bafb15739328c342354a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
SVG.Mask = function Mask() {
  this.constructor.call(this, SVG.create('mask'));
  
  /* set unique id */
  this.attr('id', (this.id = 'svgjs_element_' + (SVG.did++)));
};

// Inherit from SVG.Container
SVG.Mask.prototype = new SVG.Container();

SVG.extend(SVG.Element, {
  
  // Distribute mask to svg element
  maskWith: function(element) {
    return this.attr('mask', 'url(#' + (element instanceof SVG.Mask ? element : this.parent.mask().add(element)).id + ')');
  }
  
});