blob: 95621622d1e99625b2ec0b9d73e77fb187b12716 (
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
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)
}
})
|