-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
76 lines (60 loc) · 1.47 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
75
76
<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
fill-opacity: 1;
stroke: #777;
}
path.penta {
fill: #000;
}
path.hexa {
fill: #eee;
}
circle {
fill: none;
stroke: #333;
stroke-width: 0.5px;
}
</style>
<body>
<script src="https://d3js.org/d3.v2.min.js?2.9.6"></script>
<!-- <script src="http://d3js.org/d3.v3.min.js"></script> -->
<script src="buckyball.js"></script>
<script>
var width = 960,
height = 500;
var origin = [0, 0],
velocity = [-.01, .02],
t0 = Date.now();
var projection = d3.geo.azimuthal()
.mode("orthographic")
.origin(origin)
.scale(240);
var circle = d3.geo.circle()
.origin(origin);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
svg.append("path")
.attr("class", "penta")
.datum(d3.geodesic.pentagons());
svg.append("path")
.attr("class", "hexa")
.datum(d3.geodesic.hexagons());
// .datum(d3.geodesic.multilinestring(1));
// .datum(d3.geodesic.multipolygon(1));
svg.append("circle")
.attr("transform", "translate(" + projection(origin) + ")")
.attr("r", 240);
d3.timer(function() {
var t = Date.now() - t0,
o = [origin[0] + t * velocity[0], origin[1] + t * velocity[1]];
projection.origin(o);
circle.origin(o);
svg.selectAll("path").attr("d", function(d) { return path(circle.clip(d)); });
// svg.selectAll("path").attr("d", function(d) { return path(d); });
});
</script>