diff options
author | wout <wout@impinc.co.uk> | 2013-01-04 19:12:16 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-01-04 19:12:16 +0100 |
commit | 2380c67d4ddded556617760b4b3cb38a1d7758e2 (patch) | |
tree | c0bd5ee57a4c83e5d8860becba7766188344eda3 /src/svg.js | |
parent | 40de19951d0a4218ee2625fa9a1a69f04e79692d (diff) | |
download | svg.js-2380c67d4ddded556617760b4b3cb38a1d7758e2.tar.gz svg.js-2380c67d4ddded556617760b4b3cb38a1d7758e2.zip |
Made code more readable and included docs
Diffstat (limited to 'src/svg.js')
-rw-r--r-- | src/svg.js | 36 |
1 files changed, 23 insertions, 13 deletions
@@ -1,21 +1,31 @@ +// Use the `svg()` function to create a SVG document within a given html element. The first argument can either be an id of the element or the selected element itself. +// +// var draw = svg('paper').size(300, 300); +// var rect = draw.rect(100, 100).attr({ fill: '#f06' }); + + + +// Shortcut for creating a svg document +this.svg = function(e) { + return new SVG.Doc(e); +}; + +// The main wrapping element this.SVG = { - // define default namespaces + // Default namespaces ns: 'http://www.w3.org/2000/svg', xlink: 'http://www.w3.org/1999/xlink', - - // initialize defs id sequence - did: 0, - - // method for element creation - create: function(e) { - return document.createElementNS(this.ns, e); + // Defs id sequence + did: 0, + // Method for element creation + create: function(element) { + return document.createElementNS(this.ns, element); }, - - // method for extending objects - extend: function(o, m) { - for (var k in m) - o.prototype[k] = m[k]; + // Method for extending objects + extend: function(object, module) { + for (var key in module) + object.prototype[key] = module[key]; } };
\ No newline at end of file |