-
Notifications
You must be signed in to change notification settings - Fork 0
/
winamp.ts
41 lines (36 loc) · 895 Bytes
/
winamp.ts
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
import { Chart, d3 } from './chart'
const speed = 3000
new Chart({
element: 'viz',
margin: 0,
height: 340,
width: 600,
nav: false,
}).scratchpad((chart) => {
chart.svg
.selectAll('line')
.data(new Array(50))
.enter()
.append('line')
.attr('x1', (d, i) => i * 5)
.attr('y1', 0)
.attr('x2', (d, i) => i * 15)
.attr('y2', chart.height)
function animate() {
const top = (Math.random() - 0.5) * 50,
bottom = (Math.random() - 0.5) * 50,
offset_top = Math.random() * 300,
offset_bottom = Math.random() * 300
chart.svg
.selectAll('line')
.transition()
.ease(d3.easeQuad)
.duration(speed)
.attr('x1', (d, i) => i * top + offset_top + i * i * 0.1)
.attr('x2', (d, i) => i * bottom + offset_bottom + i * i * 0.1)
}
animate()
window.setInterval(function () {
animate()
}, speed)
})