forked from KartikTalwar/Particles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
74 lines (58 loc) · 1.39 KB
/
index.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<title>Particles!</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.25.0"></script>
<style type="text/css">
#frame
{
background-color : #000;
}
</style>
</head>
<body>
<div id="frame"></div>
<script type="text/javascript">
var box = d3.select("#frame")
.append("svg")
.attr("width", 900)
.attr("height", 600)
//.append("circle")
//.attr("r", 100)
//.attr("cx", 150)
//.attr("cy", 150)
//.style("pointer-events", "all")
.on("mousemove", paint);
function bounce()
{
d3.select(this)
.transition()
.attr("r", 50)
.duration(600)
.ease("elastic");
}
function dance()
{
d3.select(this)
.transition()
.attr("r", 110)
.duration(600)
.ease("elastic")
.each("end", bounce);
}
function paint()
{
var m = d3.mouse(this);
box.append("circle")
.attr("cx", m[0])
.attr("cy", m[1])
.style("stroke", "gray")
.transition()
.duration(1000)
.attr("r", 100)
.style("stroke-opacity", 0.001)
.remove();
}
</script>
</body>
</html>