diff options
author | wout <wout@impinc.co.uk> | 2013-07-25 13:09:30 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-07-25 13:09:30 +0100 |
commit | 58f10a25dbee327f496eacbf7944a561708de5ea (patch) | |
tree | 89647de589f46d40aaf01258240f8d6ad9390322 /src/array.js | |
parent | 494535622842ac8636a85c485b3057e8aa0dc5a7 (diff) | |
download | svg.js-58f10a25dbee327f496eacbf7944a561708de5ea.tar.gz svg.js-58f10a25dbee327f496eacbf7944a561708de5ea.zip |
Added SVG.Array and bumped to v0.29
Diffstat (limited to 'src/array.js')
-rw-r--r-- | src/array.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/array.js b/src/array.js new file mode 100644 index 0000000..a955db9 --- /dev/null +++ b/src/array.js @@ -0,0 +1,32 @@ +// Module for array conversion +SVG.Array = function(array, fallback) { + this.value = array || [] + + if (this.value.length == 0 && fallback) + this.value = fallback +} + +SVG.extend(SVG.Array, { + // Convert array to string + toString: function() { + var array = [] + + /* detect array type */ + if (Array.isArray(this.value[0])) { + /* it is a poly point string */ + for (var i = 0, il = this.value.length; i < il; i++) + array.push(this.value[i].join(',')) + + } else { + /* it's a regular array */ + array = this.value + } + + return array.join(' ') + } + // Real value +, valueOf: function() { + return this.value + } + +})
\ No newline at end of file |