summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-07-02 14:36:09 +0100
committerwout <wout@impinc.co.uk>2013-07-02 14:36:09 +0100
commitc30c718d904dc35bd99595ab37d5bb8cac796570 (patch)
tree58774563c7cc8393e21774fae98dc730115efca2 /src
parentf492d5d57790e4f3606a3370b1e676a38a9fd7a9 (diff)
downloadsvg.js-c30c718d904dc35bd99595ab37d5bb8cac796570.tar.gz
svg.js-c30c718d904dc35bd99595ab37d5bb8cac796570.zip
Added memory module
Diffstat (limited to 'src')
-rw-r--r--src/default.js6
-rw-r--r--src/memory.js34
2 files changed, 37 insertions, 3 deletions
diff --git a/src/default.js b/src/default.js
index 113e283..344fa6e 100644
--- a/src/default.js
+++ b/src/default.js
@@ -11,8 +11,8 @@ SVG.defaults = {
, 'stroke-width': 0
, 'stroke-linejoin': 'miter'
, 'stroke-linecap': 'butt'
- , fill: '#000'
- , stroke: '#000'
+ , fill: '#000000'
+ , stroke: '#000000'
, opacity: 1
/* position */
, x: 0
@@ -29,7 +29,7 @@ SVG.defaults = {
/* gradient */
, offset: 0
, 'stop-opacity': 1
- , 'stop-color': '#000'
+ , 'stop-color': '#000000'
}
// Default transformation values
diff --git a/src/memory.js b/src/memory.js
new file mode 100644
index 0000000..336716a
--- /dev/null
+++ b/src/memory.js
@@ -0,0 +1,34 @@
+SVG.extend(SVG.Element, {
+ // Initialize local memory object
+ _memory: {}
+
+ // Remember arbitrary data
+, remember: function(k, v) {
+ /* remember every item in an object individually */
+ if (typeof arguments[0] == 'object')
+ for (var v in k)
+ this.remember(v, k[v])
+
+ /* retrieve memory */
+ else if (arguments.length == 1)
+ return this._memory[k]
+
+ /* store memory */
+ else
+ this._memory[k] = v
+
+ return this
+ }
+
+ // Erase a given memory
+, forget: function() {
+ if (arguments.length == 0)
+ this._memory = {}
+ else
+ for (var i = arguments.length - 1; i >= 0; i--)
+ delete this._memory[arguments[i]]
+
+ return this
+ }
+
+}) \ No newline at end of file