diff options
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 |