aboutsummaryrefslogtreecommitdiffstats
path: root/src/mask.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/mask.js')
-rwxr-xr-xsrc/mask.js62
1 files changed, 32 insertions, 30 deletions
diff --git a/src/mask.js b/src/mask.js
index 2aa53d7..84d75b8 100755
--- a/src/mask.js
+++ b/src/mask.js
@@ -1,31 +1,42 @@
-SVG.Mask = function() {
- this.constructor.call(this, SVG.create('mask'))
+SVG.Mask = SVG.invent({
+ // Initialize node
+ create: function() {
+ this.constructor.call(this, SVG.create('mask'))
- /* keep references to masked elements */
- this.targets = []
-}
+ /* keep references to masked elements */
+ this.targets = []
+ }
-// Inherit from SVG.Container
-SVG.Mask.prototype = new SVG.Container
+ // Inherit from
+, inherit: SVG.Container
-//
-SVG.extend(SVG.Mask, {
- // Unmask all masked elements and remove itself
- remove: function() {
- /* unmask all targets */
- for (var i = this.targets.length - 1; i >= 0; i--)
- if (this.targets[i])
- this.targets[i].unmask()
- delete this.targets
+ // Add class methods
+, extend: {
+ // Unmask all masked elements and remove itself
+ remove: function() {
+ /* unmask all targets */
+ for (var i = this.targets.length - 1; i >= 0; i--)
+ if (this.targets[i])
+ this.targets[i].unmask()
+ delete this.targets
- /* remove mask from parent */
- this.parent.removeElement(this)
-
- return this
+ /* remove mask from parent */
+ this.parent.removeElement(this)
+
+ return this
+ }
+ }
+
+ // Add parent method
+, construct: {
+ // Create masking element
+ mask: function() {
+ return this.defs().put(new SVG.Mask)
+ }
}
})
-//
+
SVG.extend(SVG.Element, {
// Distribute mask to svg element
maskWith: function(element) {
@@ -45,12 +56,3 @@ SVG.extend(SVG.Element, {
}
})
-
-//
-SVG.extend(SVG.Container, {
- // Create masking element
- mask: function() {
- return this.defs().put(new SVG.Mask)
- }
-
-}) \ No newline at end of file