blob: 01b8ba5fd5f15785c7f1fc5763dec3cd42c330b0 (
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
33
34
35
36
37
38
39
40
41
42
43
|
SVG.utils = {
// Map function
map: function (array, block) {
var i
var il = array.length
var result = []
for (i = 0; i < il; i++) {
result.push(block(array[i]))
}
return result
},
// Filter function
filter: function (array, block) {
var i
var il = array.length
var result = []
for (i = 0; i < il; i++) {
if (block(array[i])) { result.push(array[i]) }
}
return result
},
// Degrees to radians
radians: function (d) {
return d % 360 * Math.PI / 180
},
// Radians to degrees
degrees: function (r) {
return r * 180 / Math.PI % 360
},
filterSVGElements: function (nodes) {
return this.filter(nodes, function (el) { return el instanceof window.SVGElement })
}
}
|