blob: ddd75651c8fa7305682a605e4c3a74300af63970 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
SVG.Mask = function() {
this.constructor.call(this, SVG.create('mask'))
}
// Inherit from SVG.Container
SVG.Mask.prototype = new SVG.Container
//
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') + ')')
}
})
//
SVG.extend(SVG.Container, {
// Create masking element
mask: function() {
return this.defs().put(new SVG.Mask)
}
})
|