-
Notifications
You must be signed in to change notification settings - Fork 44
/
jsdraw
55 lines (47 loc) · 1.26 KB
/
jsdraw
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
44
45
46
47
48
49
50
51
52
53
54
55
/*****
Implemented using I2Djs framework
https://nswamy14.gitbook.io/i2djs/
https://github.com/I2Djs/I2Djs
****/
var renderer_ = i2d.svgLayer('#MySVG', { });
var parallelChain = i2d.chain.parallelChain().loop(10)
var circlesCount = 100
var radius = 100
var g = renderer_.createEl({
el: 'group',
attr: {
transform: {
translate: [renderer_.width / 2, renderer_.height / 2]
}
}
})
g.createEls((new Array(circlesCount)).fill().map(function(d, i) {
return i
}), {
el: 'circle',
attr: {
r: 5,
cx: 0,
cy: 0
},
style: {
fill: function(d) {
return 'hsl(' + ((d % 50) / 50) * 360 + ',70%, 50%)'
}
}
})
.exec(animateEachCircle)
function animateEachCircle(d) {
parallelChain.add(this.animateExe({
duration: 2000,
delay: (d % 50) * 30,
ease: 'easeInOutSin',
attr: function(f) {
this.setAttr({
cx: radius * Math.cos(f * Math.PI * 2 + Math.PI * Math.floor(d / 50)) + (-radius + Math.floor(d / 50) * radius * 2),
cy: radius * Math.sin(f * Math.PI * 2 + Math.PI * Math.floor(d / 50))
})
}
}))
}
parallelChain.start()