summaryrefslogtreecommitdiffstats
path: root/src/array.js
blob: a955db9b5247fea45141f9676c4ecc091e506293 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
	}

})