summaryrefslogtreecommitdiffstats
path: root/src/svg.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/svg.js')
-rwxr-xr-xsrc/svg.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/svg.js b/src/svg.js
index a18e1ca..d91e2f8 100755
--- a/src/svg.js
+++ b/src/svg.js
@@ -55,6 +55,30 @@ SVG.extend = function() {
SVG.Set.inherit()
}
+// Invent new element
+SVG.invent = function(config) {
+ /* create element initializer */
+ var initializer = typeof config.create == 'function' ?
+ config.create :
+ function() {
+ this.constructor.call(this, SVG.create(config.create))
+ }
+
+ /* inherit prototype */
+ if (config.inherit)
+ initializer.prototype = new config.inherit
+
+ /* extend with methods */
+ if (config.extend)
+ SVG.extend(initializer, config.extend)
+
+ /* attach construct method to parent */
+ if (config.construct)
+ SVG.extend(config.parent || SVG.Container, config.construct)
+
+ return initializer
+}
+
// Initialize parsing element
SVG.prepare = function(element) {
/* select document body and create invisible svg element */