From 58f10a25dbee327f496eacbf7944a561708de5ea Mon Sep 17 00:00:00 2001 From: wout Date: Thu, 25 Jul 2013 13:09:30 +0100 Subject: Added SVG.Array and bumped to v0.29 --- src/array.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/array.js (limited to 'src/array.js') 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 -- cgit v1.2.3